Skip to content
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

materialize-databricks: quote schema and volume identifier #1296

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion materialize-databricks/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func newTransactor(
}

// Create volume for storing staged files
if _, err := d.store.conn.ExecContext(ctx, fmt.Sprintf("CREATE VOLUME IF NOT EXISTS %s.%s;", cfg.SchemaName, volumeName)); err != nil {
if _, err := d.store.conn.ExecContext(ctx, fmt.Sprintf("CREATE VOLUME IF NOT EXISTS `%s`.`%s`;", cfg.SchemaName, volumeName)); err != nil {
return nil, fmt.Errorf("Exec(CREATE VOLUME IF NOT EXISTS %s;): %w", volumeName, err)
}

Expand Down
14 changes: 7 additions & 7 deletions tests/materialize/materialize-databricks/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ function dropTable() {
}

# Remove materialized tables.
dropTable "\`$DATABRICKS_CATALOG\`.default.simple"
dropTable "\`$DATABRICKS_CATALOG\`.default.duplicate_keys_standard"
dropTable "\`$DATABRICKS_CATALOG\`.default.duplicate_keys_delta"
dropTable "\`$DATABRICKS_CATALOG\`.default.duplicate_keys_delta_exclude_flow_doc"
dropTable "\`$DATABRICKS_CATALOG\`.default.multiple_types"
dropTable "\`$DATABRICKS_CATALOG\`.default.formatted_strings"
dropTable "\`$DATABRICKS_CATALOG\`.\`some-schema\`.simple"
dropTable "\`$DATABRICKS_CATALOG\`.\`some-schema\`.duplicate_keys_standard"
dropTable "\`$DATABRICKS_CATALOG\`.\`some-schema\`.duplicate_keys_delta"
dropTable "\`$DATABRICKS_CATALOG\`.\`some-schema\`.duplicate_keys_delta_exclude_flow_doc"
dropTable "\`$DATABRICKS_CATALOG\`.\`some-schema\`.multiple_types"
dropTable "\`$DATABRICKS_CATALOG\`.\`some-schema\`.formatted_strings"

yes | dbsqlcli -e "delete from \`$DATABRICKS_CATALOG\`.\`default\`.flow_materializations_v2 where MATERIALIZATION='tests/materialize-databricks/materialize';"
yes | dbsqlcli -e "delete from \`$DATABRICKS_CATALOG\`.\`some-schema\`.flow_materializations_v2 where MATERIALIZATION='tests/materialize-databricks/materialize';"

14 changes: 7 additions & 7 deletions tests/materialize/materialize-databricks/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ function exportToJsonl() {
dbsqlcli -e "SELECT * FROM $1;" | mlr --icsv --ojsonl cat | jq -c "{ table: \"$1\", row: . }"
}

exportToJsonl "\`$DATABRICKS_CATALOG\`.default.simple"
exportToJsonl "\`$DATABRICKS_CATALOG\`.default.duplicate_keys_standard"
exportToJsonl "\`$DATABRICKS_CATALOG\`.default.duplicate_keys_delta"
exportToJsonl "\`$DATABRICKS_CATALOG\`.default.duplicate_keys_delta_exclude_flow_doc"
exportToJsonl "\`$DATABRICKS_CATALOG\`.default.multiple_types"
exportToJsonl "\`$DATABRICKS_CATALOG\`.\`some-schema\`.simple"
exportToJsonl "\`$DATABRICKS_CATALOG\`.\`some-schema\`.duplicate_keys_standard"
exportToJsonl "\`$DATABRICKS_CATALOG\`.\`some-schema\`.duplicate_keys_delta"
exportToJsonl "\`$DATABRICKS_CATALOG\`.\`some-schema\`.duplicate_keys_delta_exclude_flow_doc"
exportToJsonl "\`$DATABRICKS_CATALOG\`.\`some-schema\`.multiple_types"

# due to a bug in the cli, we can't use this at the moment,
# see https://github.com/databricks/databricks-sql-cli/issues/51
# exportToJsonl "\`$DATABRICKS_CATALOG\`.default.formatted_strings"
dbsqlcli -e "SELECT id, datetime::string, date::string, flow_published_at, int_and_str, int_str, num_and_str, num_str, time, flow_document FROM main.default.formatted_strings;" | \
mlr --icsv --ojsonl cat | jq -c "del(.flow_document) | { table: \"\`$DATABRICKS_CATALOG\`.default.formatted_strings\", row: . }"
dbsqlcli -e "SELECT id, datetime::string, date::string, flow_published_at, int_and_str, int_str, num_and_str, num_str, time, flow_document FROM main.\`some-schema\`.formatted_strings;" | \
mlr --icsv --ojsonl cat | jq -c "del(.flow_document) | { table: \"\`$DATABRICKS_CATALOG\`.\`some-schema\`.formatted_strings\", row: . }"
2 changes: 1 addition & 1 deletion tests/materialize/materialize-databricks/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ config_json_template='{
"address": "$DATABRICKS_HOST_NAME",
"http_path": "$DATABRICKS_HTTP_PATH",
"catalog_name": "$DATABRICKS_CATALOG",
"schema_name": "default",
"schema_name": "some-schema",
"advanced": { "updateDelay": "0s" },
"credentials": {
"auth_type": "PAT",
Expand Down
Loading
Loading