Skip to content

[source-mssql, cdk]: cherry-pick PR #55701 - #55709

Merged
Yue Li (theyueli) merged 5 commits into
masterfrom
devin/1741740669-cherry-pick-cdk-bump
Mar 14, 2025
Merged

Yue Li (theyueli) merged 5 commits into
masterfrom
devin/1741740669-cherry-pick-cdk-bump

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Cherry-pick PR #55701, bump CDK version, use local CDK for source-mssql

What

How

  • Added filter to ensure only tables with the exact requested name are returned in the discoverTable method
  • Updated version.properties to increment the patch version
  • Created CHANGELOG.md for source-mssql
  • Set useLocalCdk = true in source-mssql's build.gradle

Related Issues

Fixes #53610

Link to Devin run

https://app.devin.ai/sessions/c96ec1e59ec94c9699860b3c3d443008

Requested by: yue.li@airbyte.io

@devin-ai-integration
devin-ai-integration Bot requested review from a team as code owners March 12, 2025 00:52
@vercel

vercel Bot commented Mar 12, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 1:04am

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

Original prompt from yue.li@airbyte.io:

hi @Devin, could you help create a PR for airbyte repository which cherry picks change from this PR:
<https://github.com/airbytehq/airbyte/pull/55701>

meanwhile, bumps up the CDK version (in version.properties, airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties), and update the change log.

also, let source-mssql to use the local cdk. This is done by setting useLocalCdk = true in build.gradle under airbyte-integrations/connectors/source-mssql/build.gradle

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@@ -0,0 +1,6 @@
# Changelog

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.

instead of updating this changelog, please update this one instead:

docs/integrations/sources/mssql.md

Co-Authored-By: yue.li@airbyte.io <yue.li@airbyte.io>
@theyueli Yue Li (theyueli) changed the title fix(source-mssql): cherry-pick PR #55701, bump CDK version, use local CDK [source-mssql, cdk]: cherry-pick PR #55701 Mar 12, 2025
Co-Authored-By: yue.li@airbyte.io <yue.li@airbyte.io>
Co-Authored-By: yue.li@airbyte.io <yue.li@airbyte.io>
}
.values
.map { fields: List<JsonNode> -> jsonFieldListToTableInfo(fields) }
.filter { ti: TableInfo<CommonField<Datatype>> -> ti.name == tableName }

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.

the filter suggests that somehow fields belonging to activity index get mixed with fields belonging to activity_index (with _) but it's not clear to me why as the two strings are not equal.

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.

One reason would be lack of correct quotation or escaping in connection.metaData.getColumns(getCatalog(database), schema, tableName, null) which causes both tables to match.
I'm checking if this is the case.

@rodireich Rodi Reich Zilberman (rodireich) Mar 14, 2025 •

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.

This suggests we may need to escape as the call translates into WHERE name LIKE …

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Hi Rodi Reich Zilberman (@rodireich),

Thanks for your question about the filter in AbstractJdbcSource.kt. The filter ti.name == tableName is necessary because of how JDBC's getColumns() method works.

The getColumns() method takes a tableNamePattern parameter which is treated as a SQL LIKE pattern, not an exact match. According to the JDBC specification, this parameter supports wildcard characters like '%' (matches any sequence of characters) and '_' (matches any single character).

When we call connection.metaData.getColumns(getCatalog(database), schema, tableName, null), the database might return metadata for multiple tables that match the pattern, not just the exact table name we're looking for. This is especially true in databases like MSSQL where pattern matching behavior can vary.

For example, if we're looking for a table named "activity_index", the JDBC driver might also return tables with names like:

  • "activity_index_backup"
  • "activity_index_temp"
  • Or even tables with special characters or spaces that match the pattern

The filter ensures we only process the exact table we requested, preventing potential null pointer exceptions or incorrect data processing when multiple tables are returned.

This fix was implemented to address issue #53610 where NullPointerExceptions were occurring during table discovery.

You're right that lack of proper quotation or escaping in the JDBC call could be part of the issue. The StackOverflow link you shared confirms this behavior - the JDBC metadata query essentially translates to WHERE name LIKE <tableNamePattern>, which can match multiple tables if not properly filtered.

@rodireich Rodi Reich Zilberman (rodireich) 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.

The suggested fix is good enough I think.
A more perfect way to deal with this situation would be to ensure that connection.metaData.getColumns() do an exact match. but this isn't fully clear if there's a way to that.

@theyueli
Yue Li (theyueli) merged commit 03b7b9b into master Mar 14, 2025
@theyueli
Yue Li (theyueli) deleted the devin/1741740669-cherry-pick-cdk-bump branch March 14, 2025 23:03
Sven Pöche (Valgard) pushed a commit to mayflower/airbyte that referenced this pull request Mar 25, 2025
Co-authored-by: Baptiste Bergmann <baptiste.bergmann@maxa.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: yue.li@airbyte.io <yue.li@airbyte.io>

This branch was successfully deployed

1 active deployment
Preview — b81feee0 Deployed Mar 12, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[source-mysql] NullPointerException: ...TableInfo.getFields()" because "table" is null

5 participants