jpisaac commented on code in PR #2060:
URL: https://github.com/apache/phoenix/pull/2060#discussion_r1936671200
##########
phoenix-core-client/src/main/java/org/apache/phoenix/schema/PTableImpl.java:
##########
@@ -2516,6 +2479,41 @@ public Map<PTableKey, Long>
getAncestorLastDDLTimestampMap() {
return ancestorLastDDLTimestampMap;
}
+ private static PColumn getCompatibleColumnTypeForClientVersion(PColumn
column, String schemaName, String tableName, String columnName, long
clientVersion) {
+ LOGGER.info("getCompatibleColumnTypeForVersion for column Name {}.{},
{}, version{} ",schemaName, tableName, columnName, clientVersion);
+ if
((column.getName().getString().equalsIgnoreCase(PhoenixDatabaseMetaData.ROW_KEY_MATCHER
)
+ ||
column.getName().getString().equalsIgnoreCase(PhoenixDatabaseMetaData.PARTITION_START_KEY)
+ ||
column.getName().getString().equalsIgnoreCase(PhoenixDatabaseMetaData.PARTITION_END_KEY))
+ && clientVersion <
MetaDataProtocol.MIN_VERSION_ALLOW_VBE_COLUMNS) {
+ PColumn backwardCompatibleColumn =
+ new PColumnImpl(column.getName(),
+ column.getFamilyName(),
+ PVarbinary.INSTANCE,
+ column.getMaxLength(),
+ column.getScale(),
+ column.isNullable(),
+ column.getPosition(),
+ column.getSortOrder(),
+ column.getArraySize(),
+ column.getViewConstant(),
+ column.isViewReferenced(),
+ column.getExpressionStr(),
+ column.isRowTimestamp(),
+ column.isDynamic(),
+ column.getColumnQualifierBytes(),
+ column.getTimestamp());
+
+ LOGGER.info("Adapting field type to {} from {}, MIN_CATALOG_TS {},
CLIENT_VERSION {}, MIN_ALLOWED_VERSION {}",
+ backwardCompatibleColumn.getDataType().getSqlTypeName(),
+ column.getDataType().getSqlTypeName(),
+ MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP,
+ clientVersion,
+ MetaDataProtocol.MIN_VERSION_ALLOW_VBE_COLUMNS);
+ return backwardCompatibleColumn;
Review Comment:
We typically do not pass nulls in the List<PColumn> and the downstream code
paths are not explicitly checking for nulls, thus gives a NullPointer
exception.
If we skip the column all together then it gives another exception, I guess
since there is a column count mismatch OR and some other logic error (haven't
had a chance to debug)
Error: ERROR 203 (22005): Type mismatch. expected: [UNSIGNED_TINYINT] but
was: BIGINT at SQLINDEXTYPE argument 1 (state=22005,code=203)
org.apache.phoenix.schema.ArgumentTypeMismatchException: ERROR 203 (22005):
Type mismatch. expected: [UNSIGNED_TINYINT] but was: BIGINT at SQLINDEXTYPE
argument 1
at
org.apache.phoenix.parse.FunctionParseNode.validateFunctionArguement(FunctionParseNode.java:215)
at
org.apache.phoenix.parse.FunctionParseNode.validate(FunctionParseNode.java:194)
at
org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:327)
at
org.apache.phoenix.compile.ProjectionCompiler$SelectClauseVisitor.visitLeave(ProjectionCompiler.java:779)
at
org.apache.phoenix.compile.ProjectionCompiler$SelectClauseVisitor.visitLeave(ProjectionCompiler.java:659)
at
org.apache.phoenix.parse.FunctionParseNode.accept(FunctionParseNode.java:87)
at
org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:452)
at
org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:755)
at
org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:668)
at
org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:246)
at
org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:177)
at
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:722)
at
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:685)
at
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:360)
at
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:341)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:341)
at
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:327)
at
org.apache.phoenix.jdbc.PhoenixPreparedStatement.executeQuery(PhoenixPreparedStatement.java:195)
at
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.getTables(PhoenixDatabaseMetaData.java:1425)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sqlline.Reflector.invoke(Reflector.java:75)
at sqlline.Commands.metadata(Commands.java:202)
at sqlline.Commands.tables(Commands.java:340)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
at sqlline.SqlLine.dispatch(SqlLine.java:643)
at sqlline.SqlLine.begin(SqlLine.java:510)
at sqlline.SqlLine.start(SqlLine.java:233)
at sqlline.SqlLine.main(SqlLine.java:175)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]