Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for ibis.dtype("geospatial:geometry") #10170

Closed
1 task done
Riezebos opened this issue Sep 19, 2024 · 1 comment · Fixed by #10171
Closed
1 task done

feat: Support for ibis.dtype("geospatial:geometry") #10170

Riezebos opened this issue Sep 19, 2024 · 1 comment · Fixed by #10171
Labels
feature Features or general enhancements
Milestone

Comments

@Riezebos
Copy link
Contributor

Is your feature request related to a problem?

I wanted to store the schema of a table in a json file so that I can easily compare/convert new data extractions to the existing schema. If I try to convert the schema to a regular dictionary and back I get an error:

pairs = {n: str(t) for n, t in table.schema().fields.items()}
ibis.schema(pairs)

Output:

SignatureValidationError: Schema({'id': 'String', 'created_at': 'String', 'updated_at': 'String', 'removed': 'Boolean', 'description': 'Null', 'location': 'GeoSpatial', 'user_by_created_by': 'Struct', 'campaign': 'Struct', 'postertype': 'Null'}) has failed due to the following errors:
  `fields`: {'id': 'String', 'created_at': 'String', 'updated_at': 'String', 'removed': 'Boolean', 'description': 'Null', 'location': 'GeoSpatial', 'user_by_created_by': 'Struct', 'campaign': 'Struct', 'postertype': 'Null'} is not matching GenericMappingOf(key=InstanceOf(type=<class 'str'>), value=CoercedTo(type=<class 'ibis.expr.datatypes.core.DataType'>, func=<bound method DataType.__coerce__ of <class 'ibis.expr.datatypes.core.DataType'>>), type=CoercedTo(type=<class 'ibis.common.collections.FrozenOrderedDict'>, func=<class 'ibis.common.collections.FrozenOrderedDict'>))

Expected signature: Schema(fields: FrozenOrderedDict[str, DataType])

If I remove geospatial: from the type, it works:

pairs = {n: str(t).replace("geospatial:", "") for n, t in table.schema().fields.items()}
ibis.schema(pairs=pairs)

Output:

ibis.Schema {
  id                  string
  created_at          string
  updated_at          string
  removed             boolean
  description         null
  location            geospatial:geometry
  user_by_created_by  struct<email: string, id: string, name: string>
  campaign            struct<country: string, election: struct<electionDay: string, id: string, name: string>, id: string, name: string, region: string>
  postertype          null
}

What is the motivation behind your request?

No response

Describe the solution you'd like

I'd like all string conversions of datatypes to convert back to the original type when used in ibis.dtype()

What version of ibis are you running?

9.5.0

What backend(s) are you using, if any?

DuckDB with spatial extension

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Riezebos Riezebos added the feature Features or general enhancements label Sep 19, 2024
@cpcloud
Copy link
Member

cpcloud commented Sep 19, 2024

Thanks for the report!

We should definitely support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements
Projects
Archived in project
2 participants