Allow user to control how unsupported JDBC type should be handled#1182
Conversation
|
Better version of #1105 |
There was a problem hiding this comment.
This could be extracted to a helper method:
checkNull(block, position);
There was a problem hiding this comment.
I think we need a session toggle here. Otherwise SELECT * .. LIMIT 1 isn't going to work.
Add tests for the session toggle.
Also, no INSERT statements are going to work (even ones specifying column names), due to #1185.
There was a problem hiding this comment.
I will address that in separate commit.
There was a problem hiding this comment.
You can assume table creation is always in the form of CREATE TABLE table_name ....
See how @kokosing did this in io.prestosql.plugin.sqlserver.TestSqlServerIntegrationSmokeTest#withTable
There was a problem hiding this comment.
I prefer to use TestTable because it generates unique name. Here, it is not a problem, however recently I got several issues with tests that are using non unique name so I try to push the new convention.
Once you have an unique name you need something more than AutoCloseable.
There was a problem hiding this comment.
That's orthogonal. You can return TestTable that a) is autocloseable and b) has generated name, all without having people ever touch {TABLE_NAME} constant
There was a problem hiding this comment.
Updated. {TABLE_NAME} got removed.
There was a problem hiding this comment.
You can try do this without nested try-catch, i.e. try with try:
catch (Exception e) {
try (AutoCloseable self = this) {
throw e;
}
}
There was a problem hiding this comment.
This doesn't add to readability.
For now, i'd just use TABLE_NAME_PLACEHOLDER value directly, so without need to string format, like in https://github.com/prestosql/presto/blob/c74b775e103a7a239aafef1b7ca15fe6370495fe/presto-tests/src/main/java/io/prestosql/tests/datatype/CreateAsSelectDataSetup.java#L48
Later, i'd prefer to follow @kokosing 's https://github.com/prestosql/presto/blob/3f1d5d4cd0576ec012ea388055546816af0fdef5/presto-sqlserver/src/test/java/io/prestosql/plugin/sqlserver/TestSqlServerIntegrationSmokeTest.java#L72-L74
There was a problem hiding this comment.
Applied the first part.
There was a problem hiding this comment.
Define ctor where data is String without Optional
There was a problem hiding this comment.
Can you use some more esoteric data type? We should support PostgreSQL's GEOMETRY.
There was a problem hiding this comment.
Here I am using testing H2. Other types would need to add some plugins to h2. Do you think that presto-base-jdbc is going to support GEOMETRY some day?
c43bde5 to
d6d9dc9
Compare
kokosing
left a comment
There was a problem hiding this comment.
Addressed comments. Also add session properties to ignore and convert unsupported types to varchar.
There was a problem hiding this comment.
Here I am using testing H2. Other types would need to add some plugins to h2. Do you think that presto-base-jdbc is going to support GEOMETRY some day?
There was a problem hiding this comment.
Applied the first part.
There was a problem hiding this comment.
I will address that in separate commit.
There was a problem hiding this comment.
I prefer to use TestTable because it generates unique name. Here, it is not a problem, however recently I got several issues with tests that are using non unique name so I try to push the new convention.
Once you have an unique name you need something more than AutoCloseable.
04e972c to
f91965c
Compare
|
@findepi ping |
|
The unknown type part needs @martint to review it. My memory is that this is an internal detail which shouldn’t be exposed. |
There was a problem hiding this comment.
I think IGNORE should be the default.
|
Regarding the default behavior (https://github.com/prestosql/presto/pull/1182/files#r309276154), let me quote my comment from previous PR (#1105 (comment)):
|
Notice that: To me it is like regular type, which may have only single value |
f91965c to
4ec0c00
Compare
@findepi done. |
4ec0c00 to
222640d
Compare
There was a problem hiding this comment.
Why not handle the conversion in jdbcClient.toPrestoType?
There was a problem hiding this comment.
Add
assertQuery("SELECT * FROM " + table.getName(), "VALUES 1");
There was a problem hiding this comment.
use more descriptive column names, eg regular_column, unsupported_column.
There was a problem hiding this comment.
Please add a test
SELECT * FROM .. WHERE x = 'wrong value'
make sure PPD is disbaled then
222640d to
4199d27
Compare
|
@findepi Please notice that even if we have |
|
Would be helpful for #2088 |
There was a problem hiding this comment.
This is handled in toPrestoType. Here we should validate:
default:
checkState(unsupportedTypeHandling != CONVERT_TO_VARCHAR);
There was a problem hiding this comment.
Should be sufficient to add a const to StandardTypes instead of moving the class
There was a problem hiding this comment.
incl whole typeHandle
also you can pull column name from io.prestosql.plugin.jdbc.JdbcOutputTableHandle#columnNames
you can inline columnMapping now
There was a problem hiding this comment.
"Unsupported data type for column: "
There was a problem hiding this comment.
as a test in postgres, with decimal(129567) or sth
There was a problem hiding this comment.
i am not convinced this is a needed functionality. let's discuss
7234415 to
ccc636c
Compare
|
Applied comments. I removed options to map to unknown type and failing the query. Let's us revisit that later if needed. |
There was a problem hiding this comment.
"Unsupported type handling is set to %s, but toPrestoType() returned empty"
also
verify(columnMapping.isPresent() || getUnsupportedTypeHandling(session) == IGNORE, .. so that you can place it above, without else
There was a problem hiding this comment.
"is force mapped to" is not applicable wording when type is unsupported
There was a problem hiding this comment.
"unsupported type" -> "an unsupported type"
or, rather, just "Unsupported type handling strategy", as in sess prop desc
There was a problem hiding this comment.
revert? i think this should be "unreachable" now
There was a problem hiding this comment.
why the code here is so different than in super.?
There was a problem hiding this comment.
private; this class is not expected to be extended
ccc636c to
98af532
Compare
|
Addressed comments. Thank you! |
98af532 to
51860ff
Compare
There was a problem hiding this comment.
use import static com.google.common.base.Verify.verify
51860ff to
213d81e
Compare
213d81e to
9e59703
Compare
No description provided.