-
Notifications
You must be signed in to change notification settings - Fork 13
fix(csharp): metadata(csharp): empty-string catalog/schema/table arg throws HiveServer2Exception on Thrift, returns on SEA (#524) #577
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
base: main
Are you sure you want to change the base?
Changes from all commits
97a1c34
302deca
082a7f4
5f26464
71efaa2
9b70364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -806,6 +806,18 @@ protected override async Task<QueryResult> GetTablesAsync(CancellationToken canc | |
| activity?.SetTag("statement.table_types", TableTypes ?? "(none)"); | ||
| activity?.SetTag("statement.feature.enable_multiple_catalog_support", enableMultipleCatalogSupport); | ||
|
|
||
| // Issue #524: empty-string identifier -> empty result (parity with SEA); | ||
| // the Thrift RPC would otherwise raise HiveServer2Exception. | ||
| if (MetadataUtilities.HasEmptyStringIdentifier(CatalogName, SchemaName, TableName)) | ||
| { | ||
| activity?.AddEvent("statement.get_tables.returning_empty_result", [ | ||
| new("reason", "Empty-string identifier argument") | ||
| ]); | ||
| activity?.SetTag(SemanticConventions.Db.Response.ReturnedRows, 0); | ||
| activity?.AddEvent("statement.get_tables.complete"); | ||
| return MetadataSchemaFactory.CreateEmptyTablesResult(); | ||
| } | ||
|
|
||
| // Handle SPARK catalog case | ||
| HandleSparkCatalog(); | ||
| activity?.SetTag("statement.catalog_name_after_spark_handling", CatalogName ?? "(none)"); | ||
|
|
@@ -852,6 +864,19 @@ protected override async Task<QueryResult> GetColumnsAsync(CancellationToken can | |
| activity?.SetTag("statement.column_name", ColumnName ?? "(none)"); | ||
| activity?.SetTag("statement.feature.enable_multiple_catalog_support", enableMultipleCatalogSupport); | ||
|
|
||
| // Issue #524: empty-string identifier -> empty result (parity with SEA); | ||
| // the Thrift RPC would otherwise raise HiveServer2Exception. | ||
| if (MetadataUtilities.HasEmptyStringIdentifier(CatalogName, SchemaName, TableName)) | ||
| { | ||
| activity?.AddEvent("statement.get_columns.returning_empty_result", [ | ||
| new("reason", "Empty-string identifier argument") | ||
| ]); | ||
| activity?.SetTag(SemanticConventions.Db.Response.ReturnedRows, 0); | ||
| activity?.AddEvent("statement.get_columns.complete"); | ||
| return new QueryResult(0, new HiveInfoArrowStream( | ||
| MetadataSchemaFactory.CreateColumnMetadataSchema(), CreateColumnMetadataEmptyArray())); | ||
| } | ||
|
|
||
| // Handle SPARK catalog case | ||
| HandleSparkCatalog(); | ||
| activity?.SetTag("statement.catalog_name_after_spark_handling", CatalogName ?? "(none)"); | ||
|
|
@@ -916,6 +941,18 @@ protected override async Task<QueryResult> GetPrimaryKeysAsync(CancellationToken | |
| activity?.SetTag("statement.table_name", TableName ?? "(none)"); | ||
| activity?.SetTag("statement.feature.pk_fk_enabled", enablePKFK); | ||
|
|
||
| // Issue #524: empty-string identifier -> empty result (parity with SEA); | ||
| // the Thrift RPC would otherwise raise HiveServer2Exception. | ||
| if (MetadataUtilities.HasEmptyStringIdentifier(CatalogName, SchemaName, TableName)) | ||
| { | ||
| activity?.AddEvent("statement.get_primary_keys.returning_empty_result", [ | ||
| new("reason", "Empty-string identifier argument") | ||
| ]); | ||
| activity?.SetTag(SemanticConventions.Db.Response.ReturnedRows, 0); | ||
| activity?.AddEvent("statement.get_primary_keys.complete"); | ||
| return EmptyPrimaryKeysResult(); | ||
| } | ||
|
|
||
| if (ShouldReturnEmptyPkFkResult()) | ||
| { | ||
| activity?.AddEvent("statement.get_primary_keys.returning_empty_result", [ | ||
|
|
@@ -953,6 +990,20 @@ protected override async Task<QueryResult> GetCrossReferenceAsync(CancellationTo | |
| activity?.SetTag("statement.foreign_table_name", ForeignTableName ?? "(none)"); | ||
| activity?.SetTag("statement.feature.pk_fk_enabled", enablePKFK); | ||
|
|
||
| // Issue #524: empty-string identifier -> empty result (parity with SEA); | ||
| // the Thrift RPC would otherwise raise HiveServer2Exception. | ||
| if (MetadataUtilities.HasEmptyStringIdentifier( | ||
| CatalogName, SchemaName, TableName, | ||
| ForeignCatalogName, ForeignSchemaName, ForeignTableName)) | ||
| { | ||
| activity?.AddEvent("statement.get_cross_reference.returning_empty_result", [ | ||
| new("reason", "Empty-string identifier argument") | ||
| ]); | ||
| activity?.SetTag(SemanticConventions.Db.Response.ReturnedRows, 0); | ||
| activity?.AddEvent("statement.get_cross_reference.complete"); | ||
| return EmptyCrossReferenceResult(); | ||
| } | ||
|
|
||
| if (ShouldReturnEmptyPkFkResult()) | ||
| { | ||
| activity?.AddEvent("statement.get_cross_reference.returning_empty_result", [ | ||
|
|
@@ -980,6 +1031,20 @@ protected override async Task<QueryResult> GetCrossReferenceAsForeignTableAsync( | |
| activity?.SetTag("statement.foreign_catalog_name", ForeignCatalogName ?? "(none)"); | ||
| activity?.SetTag("statement.feature.pk_fk_enabled", enablePKFK); | ||
|
|
||
| // Issue #524: empty-string identifier -> empty result (parity with SEA); | ||
| // the Thrift RPC would otherwise raise HiveServer2Exception. | ||
| if (MetadataUtilities.HasEmptyStringIdentifier( | ||
| CatalogName, SchemaName, TableName, | ||
| ForeignCatalogName, ForeignSchemaName, ForeignTableName)) | ||
| { | ||
| activity?.AddEvent("statement.get_cross_reference_as_foreign_table.returning_empty_result", [ | ||
| new("reason", "Empty-string identifier argument") | ||
| ]); | ||
| activity?.SetTag(SemanticConventions.Db.Response.ReturnedRows, 0); | ||
| activity?.AddEvent("statement.get_cross_reference_as_foreign_table.complete"); | ||
| return EmptyCrossReferenceResult(); | ||
| } | ||
|
|
||
| if (ShouldReturnEmptyPkFkResult()) | ||
| { | ||
| activity?.AddEvent("statement.get_cross_reference_as_foreign_table.returning_empty_result", [ | ||
|
|
@@ -1018,6 +1083,20 @@ protected override async Task<QueryResult> GetColumnsExtendedAsync(CancellationT | |
| activity?.SetTag("statement.desc_table_extended.full_table_name", fullTableName ?? "(none)"); | ||
| activity?.SetTag("statement.desc_table_extended.can_use", canUseDescTableExtended); | ||
|
|
||
| // Issue #524: empty-string identifier -> empty result (parity with SEA and GetColumnsAsync). | ||
| // On the primary DESC TABLE EXTENDED path, BuildTableName drops an empty catalog/schema, so | ||
| // an empty catalog or schema would otherwise produce a valid identifier and return real rows, | ||
| // diverging from GetColumnsAsync. Guard here so both column APIs behave identically. | ||
| if (MetadataUtilities.HasEmptyStringIdentifier(CatalogName, SchemaName, TableName)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Low — This guard changes
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This thread asks a human reviewer to confirm that the empty-string→empty-result parity semantics (matching |
||
| { | ||
|
peco-review-bot[bot] marked this conversation as resolved.
|
||
| activity?.AddEvent("statement.get_columns_extended.returning_empty_result", [ | ||
| new("reason", "Empty-string identifier argument") | ||
| ]); | ||
| activity?.SetTag(SemanticConventions.Db.Response.ReturnedRows, 0); | ||
| activity?.AddEvent("statement.get_columns_extended.complete"); | ||
| return CreateEmptyExtendedColumnsResult(MetadataSchemaFactory.CreateColumnMetadataSchema()); | ||
| } | ||
|
|
||
| if (!canUseDescTableExtended || string.IsNullOrEmpty(fullTableName)) | ||
| { | ||
| activity?.AddEvent("statement.get_columns_extended.fallback_to_base", [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.