[Feature Request] SQL syntax for GENERATED columns in OSS
See original GitHub issueBug
Using SQL it is not possible to CREATE
or INSERT
into a table with GENERATED
columns with spark 3.2.1 and delta 1.2.0.
Describe the problem
Steps to reproduce
- download latest spark-3.2.1-bin-hadoop3.2-scala2.13
- start with
bin/spark-sql --packages io.delta:delta-core_2.13:1.2.0 --conf spark.sql.extensions=io.delta.sql.DeltaSparkSessionExtension --conf spark.sql.catalog.spark_catalog=org.apache.spark.sql.delta.catalog.DeltaCatalog
- try creating a table with a generated column:
CREATE TABLE `everts` (
event_time TIMESTAMP NOT NULL,
event_month DATE GENERATED ALWAYS AS (CAST(event_time AS DATE))
)
USING DELTA
;
- try
INSERT INTO
INSERT INTO TABLE default.events (event_time)
VALUES (timestamp(now()))
;
Observed results
neither the CREATE
nor the INSERT
(for the case the table was created with DeltaTableBuilder
) would succeed.
Expected results
Would be really great if the Delta OSS supports more of the feature announced by Databricks (otherwise it would help to communicate explicitly which features are Databricks exclusive and which are also available in the Delta OSS).
Further details
Could it be that the SQL GENERATED column syntax is supported on databricks only? Or am I missing something?
I cannot find any ‘GENERATED ALWAYS …’ related grammar in DeltaSqlBase.g4
either?
Environment information
- Delta Lake version: 1.2.0
- Spark version: 3.2.1
- Scala version: 2.13.5
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:13 (4 by maintainers)
Top Results From Across the Web
13.1.18.7 CREATE TABLE and Generated Columns
CREATE TABLE supports the specification of generated columns. Values of a generated column are computed from an expression included in the column definition ......
Read more >Generated Columns | PingCAP Docs
This document introduces the concept and usage of generated columns. Basic concepts. Unlike general columns, the value of the generated column is calculated ......
Read more >Generated (Virtual and Persistent/Stored) Columns - MariaDB
A generated column is a column in a table that cannot explicitly be set to a specific value in a DML query. Instead,...
Read more >Generated Columns in PostgreSQL - The Developer Space
This article describes different ways of setting up generated (computed) columns in different versions of PostgreSQL.
Read more >Use Delta Lake generated columns - Azure Databricks
Tables created with generated columns have a higher table writer protocol version than the default. See Table protocol versioning to understand ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Working to get this into 3.4 tracking via SPARK-41290
@kpe This is not in Spark yet. We are talking to the Spark community and hope we can get this syntax supported in Spark 3.4. It’s a SQL standard so it should not be hard to add the parser support. And you are right. We need to add this to SqlBaseParser.g4.