[ 
https://issues.apache.org/jira/browse/PHOENIX-61?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13909457#comment-13909457
 ] 

James Taylor edited comment on PHOENIX-61 at 2/22/14 6:38 PM:
--------------------------------------------------------------

I think this check is ok as-is. I think we're missing an override in 
PDataType.DECIMAL and PDataType.DATE. Though they are not coercible to each 
other, they are castable (which is the check that is failing). Something like 
this added in PDataType.DATE:
{code}
        @Override
        public boolean isCastableTo(PDataType targetType) {
            return super.isCastableTo(targetType) || 
targetType.isCoercibleTo(DECIMAL);
        }
{code}

and this in PDataType.DECIMAL:
{code}
        @Override
        public boolean isCastableTo(PDataType targetType) {
            return super.isCastableTo(targetType) || 
targetType.isCoercibleTo(TIMESTAMP);
        }
{code}

We should add an end-to-end unit test for this as well as a lower level test in 
PDataTypeTest.




was (Author: jamestaylor):
I think this check is ok as-is. I think we're missing an override in 
PDataType.DECIMAL and PDataType.DATE. Though they are not coercible to each 
other, they are castable (which is the check that is failing). Something like 
this added in PDataType.DATE
{code}
        @Override
        public boolean isCastableTo(PDataType targetType) {
            return super.isCastableTo(targetType) || 
targetType.isCoercibleTo(DECIMAL);
        }
{code}

We should add an end-to-end unit test for this as well as a lower level test in 
PDataTypeTest.



> 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)

Reply via email to