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
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
changed the title
[SQL] Implement CREATE TABLE
[SPARK-14388] [SQL] Implement CREATE TABLE
Apr 13, 2016
OK, I cherry-picked your changes and updated the comment. |
Test build #55724 has finished for PR 12363 at commit
|
OK, let's close this PR now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.