-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-12437][SQL] [WIP]Encapsulate the table and column name in quotes #10403
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
Conversation
|
@naveenminchu is there any sensible way to test this? If so, could you add a test? |
|
@naveenminchu I tried triggering a build, but it seems that I do not have sufficient rights for this (I do have them for my own PRs). |
|
Different databases have different quoting syntax. You need to use the JDBCDialect's quoting function to quote the table/column names. |
|
@rxin Agree 100% |
|
Can you add a test for this in the MySQL docker integration tests suite (see the |
|
Also, quick question: what if the name is qualified with a schema and also contains special characters? e.g. what if my user-supplied table name is something like
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this change for?
|
And +1 on adding a test. |
|
BTW if I understand this correctly it only quotes table names, but not column names? Are column names already quoted? |
|
@rxin Yes as u suggested I have used JdbcDialect Will also look in to test part |
|
@rxin & @JoshRosen Please take a quick look of changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add a table or tables to the dataPreparation function that have column names that are key words? For example:
create table escaped names (key BIGINT, long description TEXT);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pjfanning Added test as suggested
For example:
create table escaped names (key BIGINT, long description TEXT);
|
Hi Naveen - your new tests look good to me. I do notice though that you probably need to resync with master due to conflicts (there is a 'This branch has conflicts that must be resolved' warning). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah, this is kinda dense and confusing. Can you please rewrite this in a simpler fashion and add comments? This is just my drive-by first impression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can you add unit tests for this function? Not end-to-end tests, but a test which exercises this method in isolation, similar to the ones that I have in spark-redshift?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method contract here is confusing to me: is this supposed to introduce an additional layer of quotes? I find it confusing to couple both the responsibilities of quoting identifiers and parsing table names from a schema-qualified name.
I'd prefer to have this return just the table name, unquoted, and leave it up to later components to escape it. If you do think we should do quoting here, please explain that part of the API contract in the Scaladoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not a fan of this foldLeft. Can you please write this in a more clear way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping. Any updates here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will address it these week sometime
test this please