-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support session property with comma or equality sign #407
Support session property with comma or equality sign #407
Conversation
They may not rely on that, but it’s perfectly legal for someone to do within the constraints of the HTTP protocol. I think a proper fix for this is to come up with a way to encode or escape those kinds of characters. |
This would make Presto server side code consistent with client side: |
Do you have anything specific on your mind? Or any standard i should refer to? |
dff326e
to
854b30c
Compare
i still need to verify this doesn't break ODBC. |
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 would squash three last commits.
Also we need to make sure what SIMBA JDBC is using for , and ...
.
@@ -177,7 +177,7 @@ private Request buildQueryRequest(ClientSession session, String query) | |||
|
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.
too long commit message
properties.put(nameValue.get(0), urlDecode(nameValue.get(1))); | ||
} | ||
catch (IllegalArgumentException e) { | ||
throw badRequest(format("Invalid %s header: %s", headerName, e)); |
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.
can you please have a test for this?
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 exactly would you like to test?
Note that i added a test case in TestHttpRequestSessionContext
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.
How about adding a method
properties.put(nameValue.get(0), decodeHeaderValue(nameValue.get(1), headerName));
That way the catch (IllegalArgumentException)
has the smallest possible scope
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.
Good idea! In this case, the com.google.common.collect.ImmutableMap.Builder#put(K, V)
cannot really throw IllegalArgumentException
, so i will leave this as it is.
From what i can see Simba JDBC neither does |
fcb972f
to
731dee6
Compare
presto-jdbc/src/test/java/io/prestosql/jdbc/TestJdbcConnection.java
Outdated
Show resolved
Hide resolved
presto-jdbc/src/test/java/io/prestosql/jdbc/TestJdbcConnection.java
Outdated
Show resolved
Hide resolved
presto-jdbc/src/test/java/io/prestosql/jdbc/TestJdbcConnection.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/io/prestosql/server/protocol/StatementResource.java
Show resolved
Hide resolved
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.
Looks good to me. Please remember to squash before merging.
@@ -186,6 +187,28 @@ public void testSession() | |||
assertThat(listSession(connection)) | |||
.contains("join_distribution_type|BROADCAST|PARTITIONED") | |||
.contains("exchange_compression|true|false"); | |||
|
|||
try (Statement statement = connection.createStatement()) { | |||
statement.execute("SET ROLE admin"); // Required to be able to `SET SESSION hive....` |
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.
How about
// setting Hive session properties requires the admin role
statement.execute("SET ROLE admin");
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.
Done
properties.put(nameValue.get(0), urlDecode(nameValue.get(1))); | ||
} | ||
catch (IllegalArgumentException e) { | ||
throw badRequest(format("Invalid %s header: %s", headerName, e)); |
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.
How about adding a method
properties.put(nameValue.get(0), decodeHeaderValue(nameValue.get(1), headerName));
That way the catch (IllegalArgumentException)
has the smallest possible scope
This will break any older (Java) clients that were directly setting session properties containing percent signs (%), but that seems unlikely, and the easy solution is to upgrade the client. |
I am aware. Fortunately, there are very few properties than can contain arbitrary stuff.
exactly |
Sure, i squashed the fixup. |
8929a25
to
f227530
Compare
No description provided.