[ https://issues.apache.org/jira/browse/PHOENIX-61?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13906336#comment-13906336 ]
James Taylor commented on PHOENIX-61: ------------------------------------- FWIW, Phoenix does some type translation for fixed width types when they're indexed. The reason is that we need to have a representation for null which we can represent in the row key (which we don't have for fixed width types). The translation we do is: CHAR -> VARCHAR TINYINT/SMALLINT/INTEGER/LONG/DATE/TIME/TIMESTAMP -> DECIMAL Looks like the conversion back is not liking going from DECIMAL back to DATE/TIME, since it's not automatically coercible. It should, however, work if you do the conversion, as I believe the PDataType.coerceBytes call will handle it correctly. > Indexing on columns of Date/Timestamp type would lead to > ArgumentTypeMismatchException in optimize() > ---------------------------------------------------------------------------------------------------- > > Key: PHOENIX-61 > URL: https://issues.apache.org/jira/browse/PHOENIX-61 > Project: Phoenix > Issue Type: Bug > Affects Versions: 2.2.3 > Reporter: Maryann Xue > Original Estimate: 72h > Remaining Estimate: 72h > > Table: > CREATE TABLE IF NOT EXISTS "Orders" > ("OrderID" VARCHAR(10) NOT NULL PRIMARY KEY, > "CustomerID" VARCHAR(10), > "ItemID" VARCHAR(10), > "Quantity" INTEGER, > "Date" DATE); > Index: > CREATE INDEX IF NOT EXISTS "i2Orders" ON "Orders" > ("Date") > INCLUDE > ("CustomerID", "ItemID", "Quantity"); > Query: > SELECT "Date" FROM "Orders" ORDER BY "Date"; > Error Message: > org.apache.phoenix.schema.ArgumentTypeMismatchException: ERROR 203 (22005): > Type mismatch. expected: DATE but was: DECIMAL at column: Date > at > org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:286) > at > org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:273) > at > org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:131) > at > org.apache.phoenix.optimize.QueryOptimizer.addPlan(QueryOptimizer.java:187) > at > org.apache.phoenix.optimize.QueryOptimizer.optimize(QueryOptimizer.java:113) > at > org.apache.phoenix.optimize.QueryOptimizer.optimize(QueryOptimizer.java:75) > at > org.apache.phoenix.optimize.QueryOptimizer.optimize(QueryOptimizer.java:69) > at > org.apache.phoenix.compile.JoinCompiler.optimize(JoinCompiler.java:1020) > at > org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:123) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:262) > at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:251) > at > org.apache.phoenix.jdbc.PhoenixPreparedStatement.getParameterMetaData(PhoenixPreparedStatement.java:205) > at > org.apache.phoenix.jdbc.PhoenixConnection.executeStatements(PhoenixConnection.java:172) > at > org.apache.phoenix.util.PhoenixRuntime.executeStatements(PhoenixRuntime.java:248) > at > org.apache.phoenix.util.PhoenixRuntime.main(PhoenixRuntime.java:195) -- This message was sent by Atlassian JIRA (v6.1.5#6160)