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

Databricks loader: Support for generated columns #951

Closed
istreeter opened this issue Jun 24, 2022 · 0 comments
Closed

Databricks loader: Support for generated columns #951

istreeter opened this issue Jun 24, 2022 · 0 comments
Milestone

Comments

@istreeter
Copy link
Contributor

For optimum table partitioning, we want to use a auto-generated column on the date of collector timestamp. I imagine a table definition something like this:

CREATE TABLE events(
  app_id    VARCHAR(255),
  --
  -- lots of other columns here!
  --
  collector_tstamp_date DATE ALWAYS GENERATED AS (DATE(collector_tstamp))
)
PARTITIONED BY (collector_tstamp_date, event_name)

I have found that with generated columns we occasionally get exceptions with messages like:

Error Code: 0, SQL state: org.apache.hive.service.cli.HiveSQLException: Error running query: [MISSING_COLUMN] org.apache.spark.sql.AnalysisException: Column 'unstruct_event_com_acme_myevent_1' does not exist.

I think it's something to do with how we use the MERGESCHEMA copy option, without explicitly setting the table schema, and because different batches can have different sets of entities. These seems to be inconsistent with generated columns.

The solution I've found is to always specify every single column in the table in the COPY INTO statement. If the column is not in the parquet file then select it as NULL AS unstruct_event_com_acme_myevent_1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant