Skip to content

Commit

Permalink
Adding logs to track schematization (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mbobowski authored Jul 18, 2024
1 parent 7172481 commit 9905c7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ public void appendMetaColIfNotExist(final String tableName) {
*/
@Override
public boolean hasSchemaEvolutionPermission(String tableName, String role) {
LOGGER.info("Checking schema evolution permission for table {}", tableName);
checkConnection();
InternalUtils.assertNotEmpty("tableName", tableName);
String query = "show grants on table identifier(?)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@ public InsertRowsResponse get() throws Throwable {
// Simply added to the final response if it's not schema related errors
finalResponse.addError(insertError);
} else {
LOGGER.info(
"Triggering schema evolution. NonNullableColumns={}, extraColumns={}",
String.join(",", nonNullableColumns),
extraColNames == null ? "null" : String.join(",", extraColNames));
SchematizationUtils.evolveSchemaIfNeeded(
this.conn,
this.channel.getTableName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,19 @@ private void createTableIfNotExists(final String tableName) {
private void populateSchemaEvolutionPermissions(String tableName) {
if (!tableName2SchemaEvolutionPermission.containsKey(tableName)) {
if (enableSchematization) {
tableName2SchemaEvolutionPermission.put(
tableName,
boolean hasSchemaEvolutionPermission =
conn != null
&& conn.hasSchemaEvolutionPermission(
tableName, connectorConfig.get(SNOWFLAKE_ROLE)));
tableName, connectorConfig.get(SNOWFLAKE_ROLE));
LOGGER.info(
"[SCHEMA_EVOLUTION_CACHE] Setting {} for table {}",
hasSchemaEvolutionPermission,
tableName);
tableName2SchemaEvolutionPermission.put(tableName, hasSchemaEvolutionPermission);
} else {
LOGGER.info(
"[SCHEMA_EVOLUTION_CACHE] Schematization disabled. Setting false for table {}",
tableName);
tableName2SchemaEvolutionPermission.put(tableName, false);
}
}
Expand Down

0 comments on commit 9905c7f

Please sign in to comment.