Skip to content

Conversation

ClaireLytt
Copy link
Contributor

for #35925

Changes proposed in this pull request:


Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.
  • I have updated the Release Notes of the current development version. For more details, see Update Release Note

@ClaireLytt
Copy link
Contributor Author

"beeline -u \"jdbc:hive2://localhost:10000/default\" -e \"CREATE DATABASE IF NOT EXISTS encrypt; CREATE DATABASE IF NOT EXISTS expected_dataset;\"");
System.out.println("Databases created successfully in postStart()");
"beeline -u \"jdbc:hive2://localhost:10000/default\" -e \"CREATE DATABASE IF NOT EXISTS encrypt; "
+ "CREATE DATABASE IF NOT EXISTS expected_dataset; CREATE DATABASE IF NOT EXISTS mask;\"");
Copy link
Member

Choose a reason for hiding this comment

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

Why execute CREATE DATABASE IF NOT EXISTS expected_dataset; CREATE DATABASE IF NOT EXISTS mask; sql here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed this hardcoding approach in the new commit.

@@ -94,10 +94,19 @@ public void fillData() {
}
String insertSQL;
try (Connection connection = dataSourceMap.get(dataNode.getDataSourceName()).getConnection()) {
DatabaseType databaseType = DatabaseTypeFactory.get(connection.getMetaData().getURL());
insertSQL = generateInsertSQL(dataNode.getTableName(), dataSetMetaData.getColumns(), databaseType);
DatabaseType currentDatabaseType;
Copy link
Member

Choose a reason for hiding this comment

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

If we can get databaseType from class field, I think we can remove DatabaseType databaseType = DatabaseTypeFactory.get(connection.getMetaData().getURL());

@ClaireLytt
Copy link
Contributor Author

Entrypt dml test

@ClaireLytt ClaireLytt changed the title Support Hive data mask E2E Test Support Hive data mask E2E test and data encrypt DML statement test. Sep 11, 2025
return;
}
StringBuilder createDatabaseSQL = new StringBuilder();
for (String databaseName : allDatabaseNames) {
Copy link
Member

Choose a reason for hiding this comment

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

Please rename databaseName to each.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

insertSQL = generateInsertSQL(dataNode.getTableName(), dataSetMetaData.getColumns(), databaseType);
String insertTableName = dataNode.getTableName();
if ("Hive".equalsIgnoreCase(databaseType.getType())) {
insertTableName = dataNode.getDataSourceName() + "." + dataNode.getTableName();
Copy link
Member

Choose a reason for hiding this comment

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

Why add dataNode.getDataSourceName() in insertTableName?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed it.

Object value = each.getValue();
int index = each.getIndex();
if ("Hive".equalsIgnoreCase(databaseType.getType())) {
if (value instanceof Date) {
Copy link
Member

Choose a reason for hiding this comment

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

Why call setString for Date type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the Date type does not support the setObject, as you can see in the source code. I have already used the setDate which is more appropriate.

setParameters(preparedStatement, each);
preparedStatement.addBatch();
boolean isHive = "Hive".equalsIgnoreCase(databaseType.getType());
if (isHive) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you use DatabaseMetaData.supportsBatchUpdates() to judge this logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return DatabaseTypeFactory.get(url);
} catch (final SQLFeatureNotSupportedException ex) {
String driverName = connection.getMetaData().getDriverName();
if (driverName != null && driverName.toLowerCase().contains("hive")) {
Copy link
Member

Choose a reason for hiding this comment

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

Please put null on the left hand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

} catch (final SQLFeatureNotSupportedException ex) {
String driverName = connection.getMetaData().getDriverName();
if (driverName != null && driverName.toLowerCase().contains("hive")) {
return DatabaseTypeFactory.get("jdbc:hive2://localhost:10000/default");
Copy link
Member

Choose a reason for hiding this comment

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

Why not just return HiveDatabaseType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If return HiveDatabaseType ,it may lead to the occurrence of ServiceProviderNotFoundException: No implementation class load from SPI 'DialectDatabaseMetaData' with type 'null' errors, so I choose to use TypedSPILoader

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.

2 participants