-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
How to get Arrow Schema for PostgreSQL column of hstore(map) and geometry types in JdbcToArrowUtils.jdbcToArrowSchema ? #14039
Comments
I don't think it's possible; while you can override the conversion from JDBC type to Arrow type, the supported Arrow types are hardcoded: arrow/java/adapter/jdbc/src/main/java/org/apache/arrow/adapter/jdbc/JdbcToArrowUtils.java Line 414 in 50a7d15
For Map: it'd be reasonable to add support directory For geometry type: the question would be, what type do you expect this to be mapped to? And would it be useful to extend the JDBC adapter with full control over the Arrow type support, so that you can add custom types at runtime? |
Hello @lidavidm
Sounds perfect! Something similar with following snippet for schema:
binary representation is OK for me for current task
It could be good solution for custom type mapping in complex cases. I also have proposal for column/schema level metadata - propagate "comment" for table/columns here by using java.sql.DatabaseMetaData#getColumns / java.sql.DatabaseMetaData#getTables from connection.getMetaData() or just allow user to provide it from custom comment handler in JdbcToArrowConfig . It will be very useful metadata in real life (medium to large scale project) for documentation and maintenance topics. Apache Spark code use "comment" key for such metadata, so this looks like reasonable default name for metadata in Arrow schema too |
Yes - if you want to file a Jira and/or PR they would be much appreciated. (For anything here, I'm generally supportive, but I don't have too much time right now to do more than review code.)
That sounds good to me. If there's more capabilities required, you may want to follow the discussion about "canonical extension types": https://lists.apache.org/thread/qxc1g7h9ow79qt6r7sqtgbj8mdbdgnhb This would let us define a new "type" for Postgres-style geometry data which is just metadata over an existing type (such as binary).
Ok, cool. If you have an API proposal, feel free to file a Jira and/or PR - I think it makes sense to allow more flexibility here, given that we allow it in the 'opposite direction' anyways.
Interesting. A contribution would be welcome here as well - I think it makes sense to propagate the JDBC metadata into the Arrow metadata if it's useful for applications. |
Ok, let's do all things step by step: |
Thank you! |
I want to convert into Apache Arrow IPC data format in Java existing data from PostgreSQL database.
JdbcToArrowUtils.jdbcToArrowSchema allows do it for scalar types and arrays.
org.postgresql.jdbc.PgResultSetMetaData instance from PostgreSQL jdbc driver provide all required info related to column types pgResultSetMetaData.getColumnTypeName().
But looks like current implementation support only ArrowType.List with no support of Map type mapping in code
How to get Apache Arrow schema and transform data into Arrow for hstore(map) and geometry database column types?
The text was updated successfully, but these errors were encountered: