Skip to content

feat(bigquery-jdbc): add graph metadata integration for getTables and getTableTypes - #14868

Open
Neenu1995 wants to merge 14 commits into
jdbc/graph-metadata-integrationfrom
jdbc/graph-get-tables
Open

Neenu1995 wants to merge 14 commits into
jdbc/graph-metadata-integrationfrom
jdbc/graph-get-tables

Conversation

@Neenu1995

@Neenu1995 Neenu1995 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

b/570033146
b/570032972

@Neenu1995
Neenu1995 requested review from a team as code owners October 30, 2026 15:21

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for discovering Property Graphs and related metadata in the BigQuery JDBC driver via a new EnableGraphMetadata connection property. It updates BigQueryDatabaseMetaData to query INFORMATION_SCHEMA.PROPERTY_GRAPHS and expose these as 'GRAPH TABLE' types in getTables and getTableTypes. The code review feedback suggests two key improvements: dynamically padding the table metadata values with nulls to match the schema size rather than hardcoding five nulls, and gracefully catching and skipping projects on 'Permission denied' or 'Access denied' errors when querying metadata.

@Neenu1995
Neenu1995 changed the base branch from main to jdbc/graph-metadata-integration October 30, 2026 15:38
@Neenu1995
Neenu1995 requested review from a team as code owners October 30, 2026 15:38
@Neenu1995
Neenu1995 changed the base branch from jdbc/graph-metadata-integration to jdbc/graph-connection-property October 30, 2026 15:42
@Neenu1995
Neenu1995 requested a review from a team as a code owner October 30, 2026 15:42
@Neenu1995

Copy link
Copy Markdown
Contributor Author

/gcbrun

Base automatically changed from jdbc/graph-connection-property to jdbc/graph-metadata-integration October 30, 2026 16:37
@Neenu1995
Neenu1995 removed request for a team November 2, 2026 18:14
private static final String[] DEFAULT_TABLE_TYPES = {
"EXTERNAL", "MATERIALIZED VIEW", "SNAPSHOT", "TABLE", "VIEW"
};
private static final String[] TABLE_TYPES_WITH_GRAPH = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: can we update it to be DEFAULT_TABLE_TYPES + {"GRAPH TABLE"} in some way?

JSON_VALUE(t, '$.dataSourceTable.projectId'), '.',
JSON_VALUE(t, '$.dataSourceTable.datasetId'), '.',
JSON_VALUE(t, '$.dataSourceTable.tableId')) AS SOURCE_TABLE
FROM %1$s.%2$s.INFORMATION_SCHEMA.PROPERTY_GRAPHS,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add escape ``` characters for the table name

JSON_VALUE(t, '$.dataSourceTable.projectId'), '.',
JSON_VALUE(t, '$.dataSourceTable.datasetId'), '.',
JSON_VALUE(t, '$.dataSourceTable.tableId')) AS SOURCE_TABLE
FROM %1$s.%2$s.INFORMATION_SCHEMA.PROPERTY_GRAPHS,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Escape table name

boolean isExactGraphTableName =
tableNamePattern != null
&& !tableNamePattern.contains("%")
&& tableNamePattern.contains(".");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a comment explaining this assumption that if table name contains ., we'll expect it to be graph

formattedSql =
replaceSqlParameters(
getGraphTablesDatasetSqlContent(),
quoteIdentifier(project),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Per comment in SQL, rather than escaping identifiers here, better to do it at SQL file level


for (String project : targetCatalogs) {
String formattedSql;
if (isExactDataset) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I'd rather do it this way, easier to see what's changing

formattedSql =
            replaceSqlParameters(
                getGraphTablesRegionSqlContent(),
                quoteIdentifier(project),
                isExactDataset ? quoteIdentifier(effectiveSchemaPattern) : quoteIdentifier(resolveGraphRegion()));

if (isExactDataset) {
statement.setString(1, effectiveTablePattern);
} else {
statement.setString(1, effectiveSchemaPattern == null ? "%" : effectiveSchemaPattern);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can have single SQL query, having an extra condition schema LIKE "%" is unlikely to have any perf implication (other than that they seem identical);

String sourceTable = rs.getString("SOURCE_TABLE");
String remarks = sourceTable != null ? "Source: " + sourceTable : null;

List<FieldValue> values = new ArrayList<>(resultSchemaResults.size());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add inline comments what maps to what?

Assertions.assertTrue(graphTables.contains(graphName + ".Knows"));
Assertions.assertEquals(2, graphTables.size());
} finally {
try (Connection cleanupConn = DriverManager.getConnection(ITBase.connectionUrl);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: no need to cleanup. We drop entire dataset after tests which will drop tables too

// Add rows in unsorted order (based on TYPE, CAT, SCHEM, NAME)
results.add(createTableRow("cat_a", "sch_z", "table_1", "TABLE", schemaFields));
results.add(createTableRow("cat_b", "sch_a", "view_1", "VIEW", schemaFields));
results.add(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move this to the last row, so that we just append to unittest

This branch has not been deployed

No deployments
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.

3 participants