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

[SPARK-14388] [SQL] Implement CREATE TABLE #12363

Closed
wants to merge 21 commits into from
Closed

[SPARK-14388] [SQL] Implement CREATE TABLE #12363

wants to merge 21 commits into from

Conversation

yhuai
Copy link
Contributor

@yhuai yhuai commented Apr 13, 2016

This patch implements the CREATE TABLE command using the SessionCatalog. Previously we handled only CTAS and CREATE TABLE ... USING. This requires us to refactor CatalogTable to accept various fields (e.g. bucket and skew columns) and pass them to Hive.

Andrew Or and others added 21 commits April 8, 2016 14:41
We need to reconcile the differences between what's added here in
SparkSqlParser and HiveSqlParser. That will come in the next
commit.

This currently still fails tests, obviously because create table
is not implemented yet!
Before: CatalogTable has schema, partitionColumns and sortColumns.
There are no constraints between the 3. However, Hive will
complain if schema and partitionColumns overlap.

After: CatalogTable has schema, partitionColumnNames,
sortColumnNames, bucketColumnNames and skewColumnNames. All the
columns must be a subset of schema. This means splitting up
schema into (schema, partitionCols) before passing it to Hive.

This allows us to store the columns more uniformly. Otherwise
partition columns would be the odd one out. This commit also
fixes "alter table bucketing", which was incorrectly using
partition columns as bucket columns.
This involves reverting part of the changes in an earlier commit,
where we tried to implement the parsing logic in the general SQL
parser and introduced a bunch of case classes that we won't end
up using.

As of this commit the actual CREATE TABLE logic is not there yet.
It will come in a future commit.
We weren't using the right default serde in Hive. Note that this
still fails a test with "Reference 'ds' is ambiguous ...", but
this error is common across many tests so it will be addressed
in a future commit.
In HiveMetastoreCatalog we already combined the schema and the
partition keys to compensate for the fact that Hive separates it.
Now this logic is pushed to the edges where Spark talks to Hive.
Previously we always converted the data type string to lower case.
However, for struct fields this also converts the struct field
names to lower case. This is not what tests (or perhaps user code)
expects.
There were a few differences in DESCRIBE TABLE:
- output format should be HiveIgnoreKeyTextOutputFormat
- num buckets should be -1
- last access time should be -1
- EXTERNAL should not be set to false for managed table

After making these changes out result now matches Hive's.
CatalystSqlParser knows how to parse decimal(5)!
@yhuai yhuai changed the title [SQL] Implement CREATE TABLE [SPARK-14388] [SQL] Implement CREATE TABLE Apr 13, 2016
@andrewor14
Copy link
Contributor

OK, I cherry-picked your changes and updated the comment.

@SparkQA
Copy link

SparkQA commented Apr 13, 2016

Test build #55724 has finished for PR 12363 at commit ab70cb7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@andrewor14
Copy link
Contributor

OK, let's close this PR now.

@yhuai yhuai closed this Apr 13, 2016
@yhuai yhuai deleted the createTable branch April 13, 2016 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants