Skip to content

adapt name search from JSONTables.jl #50

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

Merged
merged 14 commits into from
Dec 19, 2022
Merged

adapt name search from JSONTables.jl #50

merged 14 commits into from
Dec 19, 2022

Conversation

rafaqz
Copy link
Member

@rafaqz rafaqz commented Oct 8, 2022

Use the JSONTables.jl methods of getting a list of column names and types. Unfortunately we cant just use their methods as we need to dig into the properties field of each object, rather than using the top level fields.

@visr this isn't quite finished, just pushing so you know I'm working on it and we don't duplicate efforts

So it turned out to be quite tricky getting this to work for both Object and NameTuple features.

There are likely still some issues with vectors of mixed field NamedTuple in broadcast or other places, but mostly things seem to be working.

See #48
Fixes #45

@rafaqz rafaqz marked this pull request as ready for review November 13, 2022 23:03
@rafaqz rafaqz requested a review from visr November 13, 2022 23:03
Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, added some comments. Great to have this.

@rafaqz
Copy link
Member Author

rafaqz commented Nov 22, 2022

The current problem is I'm not sure if null geometries are meant to be represented by nothing or missing.

There is currently a mix ob both in different contexts.

In getproperty there is this line:

 return ifelse(x === nothing, missing, x)

And tests reflect this with checks for missing. But geometry(feature) returns nothing without swapping to missing.

The main issue with this is round-tripping Feature construction doesn't always work. If you build a feature with a missing geometry show will error in the REPL because the check is for nothing.

I think we need to decide either way, and if its missing move where the swap from nothing to missing happens so its more consistent.

@visr any ideas here?

The GeoInterface.jl tests want nothing as the empty value of geometry. I guess thats why there is a split in the behaviour? Is this so the table column will be a Union{Missing,GeomType} rather than Union{Nothing,Geomtype} ?

I guess we can also swap missing to nothing in geometry and keep both behaviours. (I've implemented this now)

@rafaqz
Copy link
Member Author

rafaqz commented Dec 13, 2022

@visr do you want to have a look at this?

@visr
Copy link
Member

visr commented Dec 19, 2022

Is this so the table column will be a Union{Missing,GeomType} rather than Union{Nothing,Geomtype} ?

Yes this behavior was intended to copy JSONTables. JSON3 by default parses JSON null to nothing, and serialize both nothing and missing to null. And in Julia null elements in data/tables are usually set to missing. That is why JSONTables put some ifelse(x === nothing, missing, x) code over it, to present nothing as missing in the tables interface.

I'm not sure what the best approach is here.

@rafaqz
Copy link
Member Author

rafaqz commented Dec 19, 2022

I think how it is now is fine if you take a look at the changes

Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good, sorry for the wait.

@visr visr merged commit 67ed88c into main Dec 19, 2022
@visr visr deleted the better_columnnames branch December 19, 2022 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propertynames of feature collection falsely taken from the first element
2 participants