question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type and Field extension / change behavior

See original GitHub issue

Overview

I’m using Frictionless pretty much as Schema Detector. I have two issues here:

  1. I would like to introduce a custom type called BigInt to be able to differentiate normal Integer from a BigInt. Issue is that for how it works the detector, as soon it find a correct type (https://github.com/frictionlessdata/frictionless-py/blob/a0cd70d03df4ca6571b1e8b26445e6274ba46c3d/frictionless/detector.py#L270), it will break from the loop of the runners, invalidate in case a custom BigInteger type cause the Integer type would always succeed before.

  2. I have a issue also with datetime format, still in a scenario of schema detection. Since automatically the detector will apply a default as format, instead of a any for a timestamp, it will always arise a issue on the assert (https://github.com/frictionlessdata/frictionless-py/blob/a0cd70d03df4ca6571b1e8b26445e6274ba46c3d/frictionless/types/datetime.py#L32) avoiding in case a correct parser.parse(cell) for different format that doesn’t follow isoformat.

I’m not sure how I could patch in case these two cases, and if it’s even possible.


Please preserve this line to notify @roll (lead of this repository)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
antoniocalicommented, Aug 24, 2021

Thank you. It was very on point!

1reaction
rollcommented, Aug 5, 2021

@antoniocali Hi, from frictionless@4.16 there is a plugin.create_candidates hook. Here is a full example with a custom type:

    # Type
    class CustomType(Type):
        def read_cell(self, cell):
            return [cell] # make everything an array just for example

    # Plugin
    class CustomPlugin(Plugin):
        def create_candidates(self, candidates):
            candidates.insert(0, {"type": "custom"})

        def create_type(self, field):
            if field.type == "custom":
                return CustomType(field)

    # System
    plugin = CustomPlugin()
    system.register("custom", plugin)

That’s how system.create_candidates returns without custom plugins (a detector will try these types on an detected cell from top to bottom):

[{'type': 'yearmonth'},
 {'type': 'geopoint'},
 {'type': 'duration'},
 {'type': 'geojson'},
 {'type': 'object'},
 {'type': 'array'},
 {'type': 'datetime'},
 {'type': 'time'},
 {'type': 'date'},
 {'type': 'integer'},
 {'type': 'number'},
 {'type': 'boolean'},
 {'type': 'year'},
 {'type': 'string'}]

Using this hook you can also alter other detections details, for example, insert {'type': 'datetime', 'format': 'any'} before the default datetime candidate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contents 2 Fields and Field Extensions
Theorem (Spanning Sets): If V is a vector space, then any spanning set for V contains a basis of V . ◦ If...
Read more >
Field Extensions - GraphQL Ruby
See below for how extensions may modify fields. ... This way, an extension can encapsulate a behavior requiring several configuration options.
Read more >
Geometric interpretation of different types of field extensions?
The philosophy is that a finite field extension is the same thing as a finite morphism SpecL→SpecK. In algebraic geometry, finite morphisms of ......
Read more >
D365 F&O | Technical | My Learning | Table Extensions
Start the name of the extension class with the name of the type that is being ... Modify existing fields in a table...
Read more >
JONSSON ωo-GENERATED ALGEBRAIC FIELD EXTENSIONS
A field K algebraic over its subfield F is said to be a /-extension. (for Jόnsson ωo-generated extension) of F if K/F is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found