-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Support Hive data mask E2E test and data encrypt DML statement test. #36492
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: master
Are you sure you want to change the base?
Conversation
"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;\""); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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());
.../sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/DataSetEnvironmentManager.java
Show resolved
Hide resolved
.../sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/DataSetEnvironmentManager.java
Show resolved
Hide resolved
.../sql/src/test/java/org/apache/shardingsphere/test/e2e/sql/env/DataSetEnvironmentManager.java
Show resolved
Hide resolved
...java/org/apache/shardingsphere/test/e2e/env/container/atomic/storage/impl/HiveContainer.java
Outdated
Show resolved
Hide resolved
return; | ||
} | ||
StringBuilder createDatabaseSQL = new StringBuilder(); | ||
for (String databaseName : allDatabaseNames) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setParameters(preparedStatement, each); | ||
preparedStatement.addBatch(); | ||
boolean isHive = "Hive".equalsIgnoreCase(databaseType.getType()); | ||
if (isHive) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
for #35925
Changes proposed in this pull request:
Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e
.