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

Extract schema information from the underlying connections, add Arrow schema conversion utility #497

Merged
merged 12 commits into from
Apr 26, 2024

Conversation

geoffxy
Copy link
Member

@geoffxy geoffxy commented Apr 24, 2024

This PR modifies BRAD's connection code to extract schema information (the column names and types) from the underlying database connections. Each database has slightly different types, so we unify them in a "best effort" way for now. Later on we will have better support for specific SQL dialects.

High level summary of the changes

  • Add result_schema() to BRAD cursors
  • Define BRAD-specific DataType, Field and Schema classes
  • Add a C++ helper function that converts a Python BRAD Schema into an Arrow schema
  • Various minor modifications to pass the Python schema to the Flight SQL code

@geoffxy geoffxy requested a review from sopzha April 24, 2024 03:55
@geoffxy geoffxy self-assigned this Apr 24, 2024
std::vector<py::tuple> query_result = handle_query_(query);
transformed_query_result = TransformQueryResult(query_result);
auto result = handle_query_(query);
result_schema = ArrowSchemaFromBradSchema(result.second);
Copy link
Member Author

Choose a reason for hiding this comment

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

@sopzha This converts the Python BRAD schema into an Arrow schema that you can use. The result_schema variable is currently unused, but you can incorporate it into the rest of your code.

@sopzha sopzha merged commit 3b40183 into main Apr 26, 2024
2 checks passed
@sopzha sopzha deleted the gy-types branch April 26, 2024 02:48
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.

2 participants