Skip to content

Conversation

@eric-wang-1990
Copy link
Contributor

PR Description

Description

This PR fixes an issue with foreign key handling in the GetColumnsExtended method by refactoring the cross-reference lookup process. It extracts the foreign key lookup logic into a dedicated method and improves the handling of empty result sets.

Changes

  • Created a new GetCrossReferenceAsForeignTableAsync method to encapsulate the logic for retrieving cross-reference data where the current table is treated as a foreign table
  • Added constants for primary and foreign key field names and prefixes to improve maintainability
  • Implemented proper handling for empty result sets in GetColumnsExtendedAsync by creating a helper method CreateEmptyExtendedColumnsResult
  • Extended the Databricks driver to override the new GetCrossReferenceAsForeignTableAsync method to maintain consistency with the empty result handling logic
  • Added TODOs for future logging improvements

Motivation

The existing implementation had several issues:

  1. The foreign key lookup logic was embedded directly in the GetColumnsExtendedAsync method, making it difficult to maintain and extend, it also does not go through the child class DatabricksStatement overriden function.
  2. Empty result sets were not handled properly, potentially causing errors when no columns were returned
  3. The code lacked consistency in how it handled relationship data

Testing

The changes have been tested with both empty and populated tables to ensure proper handling of all scenarios. The refactored code maintains the same functionality while improving code organization and error handling.

Related Issues

This PR is related to the ongoing improvements in primary and foreign key metadata handling in the ADBC drivers.

@github-actions github-actions bot added this to the ADBC Libraries 19 milestone May 29, 2025
@eric-wang-1990 eric-wang-1990 changed the title fix get cross reference in getcolumnsExtended fix(csharp/src/Drivers/Apache/Hive2): improve foreign key handling in GetColumnsExtended** May 29, 2025
@eric-wang-1990 eric-wang-1990 changed the title fix(csharp/src/Drivers/Apache/Hive2): improve foreign key handling in GetColumnsExtended** fix(csharp/src/Drivers/Apache/Hive2): improve foreign key handling in GetColumnsExtended May 29, 2025
Copy link
Contributor

@CurtHagenlocher CurtHagenlocher left a comment

Choose a reason for hiding this comment

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

Thanks!

@CurtHagenlocher CurtHagenlocher merged commit f0dabb9 into apache:main Jun 2, 2025
6 checks passed
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