[
https://issues.apache.org/jira/browse/PHOENIX-3210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15453814#comment-15453814
]
James Taylor commented on PHOENIX-3210:
---------------------------------------
[~prakul] - thanks for the patch. Here's some feedback:
- Name your classes with capital letters. doubleToDecimalCastIT should be
DoubleToDecimalCastIT.
- Add this test, as it gets a bit closer to reproducing the issue. In this
case, {{value}} will be a Double, but the if statement causes this to return
true.
{code}
@Test
public void testUpsertingDoubleLiteralExprInDecimalField() throws Exception
{
String tableName = generateRandomString();
String viewName = generateRandomString();
String ddl = "CREATE TABLE " + tableName + " ( ID integer primary key,
V decimal)";
conn.createStatement().execute(ddl);
ddl = "CREATE VIEW " + viewName + " (v2 VARCHAR ) AS SELECT * FROM " +
tableName + " WHERE ID=1";
conn.createStatement().execute(ddl);
String ups = "UPSERT INTO " + viewName + "(V) VALUES (54e-1+43e-1)";
conn.createStatement().execute(ups);
conn.commit();
ResultSet rs = conn.createStatement().executeQuery("select *" +
" from " +tableName);
assertTrue(rs.next());
}
{code}
- Even though we can't repro the issue, I think your change is fine.
The issue isn't reproducible since this[1] commit, [~shehzaadn]. Maybe you saw
it prior to core being upgraded to 4.7?
[1]
https://github.com/apache/phoenix/commit/b806645335975c8b10346eece5821a8565335504
> Exception trying to cast Double to BigDecimal in UpsertCompiler
> ---------------------------------------------------------------
>
> Key: PHOENIX-3210
> URL: https://issues.apache.org/jira/browse/PHOENIX-3210
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.7.0
> Reporter: Shehzaad Nakhoda
> Assignee: prakul agarwal
> Labels: SFDC
> Fix For: 4.9.0, 4.8.1
>
> Attachments: PHOENIX-3210.patch
>
>
> We have an UPSERT statement that is resulting in this stack trace.
> Unfortunately I can't get a hold of the actual Upsert statement since we
> don't log it.
> Cause0: java.lang.ClassCastException: java.lang.Double cannot be cast to
> java.math.BigDecimal
> Cause0-StackTrace:
> at
> org.apache.phoenix.schema.types.PDecimal.isSizeCompatible(PDecimal.java:312)
> at
> org.apache.phoenix.compile.UpsertCompiler$3.execute(UpsertCompiler.java:887)
> at
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:335)
> at
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:323)
> at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
> at
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:321)
> at
> org.apache.phoenix.jdbc.PhoenixStatement.executeUpdate(PhoenixStatement.java:1274)
> at
> phoenix.connection.ProtectedPhoenixStatement.executeUpdate(ProtectedPhoenixStatement.java:127)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)