Skip to content

Fail on unknown JDBC type#1105

Closed
kokosing wants to merge 2 commits intotrinodb:masterfrom
kokosing:origin/master/139_jdbc_fail
Closed

Fail on unknown JDBC type#1105
kokosing wants to merge 2 commits intotrinodb:masterfrom
kokosing:origin/master/139_jdbc_fail

Conversation

@kokosing
Copy link
Member

Fail on unknown JDBC type

@cla-bot cla-bot bot added the cla-signed label Jul 10, 2019
@kokosing kokosing requested review from electrum, findepi and sopel39 July 10, 2019 08:44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it really be the same exception instance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know. I think I can call it a Presto convention.

@kokosing kokosing force-pushed the origin/master/139_jdbc_fail branch from 26edf94 to 8ef2620 Compare July 10, 2019 11:36
@kokosing kokosing force-pushed the origin/master/139_jdbc_fail branch from 8ef2620 to cac6b91 Compare July 10, 2019 11:42
UnsupportedTypeHandlingStrategy unsupportedTypeHandlingStrategy = getUnsupportedTypeHandlingStrategy(session);
switch (unsupportedTypeHandlingStrategy) {
case IGNORE:
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue (please add a test)

case IGNORE:
break;
case FAIL:
throw new PrestoException(JDBC_ERROR, "Unsupported data type for column: " + columnName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incl typeHandle

@Override
public List<PropertyMetadata<?>> getSessionProperties()
{
ImmutableList.Builder builder = ImmutableList.<PropertyMetadata<?>>builder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raw usage of a generic class

return unsupportedTypeHandlingStrategy;
}

@Config("unsupported-type.handling-strategy")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsupported-type.handling-strategy=FAIL is not nearly as clear as fail-on-unsupported-types=true.

I understand the enum is a preparation for an option to map unsupported columns to varchar (see also #186)
I think the option name needs to be revisited.

private String passwordCredentialName;
private boolean caseInsensitiveNameMatching;
private Duration caseInsensitiveNameMatchingCacheTtl = new Duration(1, MINUTES);
private UnsupportedTypeHandlingStrategy unsupportedTypeHandlingStrategy = FAIL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have already enough data points to determine what the default behavior should actually be?

@@ -63,6 +63,7 @@
import static com.google.common.collect.ImmutableMap.toImmutableMap;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query should fail only when user actually tries to read data from such column

@findepi
Copy link
Member

findepi commented Jul 22, 2019

I propose a different new behavior:

  • expose all columns, including those unsupported (perhaps as unknown type)
  • fail query only when it accesses unsupported columns (either explicitly, or SELECT *)

Regarding default behavior, there are different use-cases for SELECT *:

  1. copying/migrating data (usually CREAT TABLE .. AS SELECT * FROM ..)
    • in this case, the new behavior is more appropriate
  2. poking around (usually SELECT * FROM .. LIMIT 1)
    • in this case, the current behavior is more appropriate

Since current behavior is more appropriate in certain use-cases, I would not change current default behavior.

@kokosing
Copy link
Member Author

What about conversion unknown types to varchar? I think we could add only a session property that would be always set to false (no config property to overwrite that). So user could peek the data, knowing the fact that column data type is unsupported and it may change in future.

@findepi What do you think?

@electrum
Copy link
Member

Seems reasonable to me.

@kokosing
Copy link
Member Author

Replaced with #1182

@kokosing kokosing closed this Jul 26, 2019
@kokosing kokosing deleted the origin/master/139_jdbc_fail branch July 26, 2019 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants