You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Kuldeep (JIRA)" <ji...@apache.org> on 2015/01/28 16:57:34 UTC
[jira] [Updated] (SPARK-5456) Decimal Type comparison issue
[ https://issues.apache.org/jira/browse/SPARK-5456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kuldeep updated SPARK-5456:
---------------------------
Description:
Not quite able to figure this out but here is a junit test to reproduce this,
{code:title=DecimalBug.java}
@Test
public void decimalQueryTest() {
List<Row> decimalTable = new ArrayList<Row>();
decimalTable.add(RowFactory.create(new BigDecimal("1"), new BigDecimal("2")));
decimalTable.add(RowFactory.create(new BigDecimal("3"), new BigDecimal("4")));
JavaRDD<Row> rows = sc.parallelize(decimalTable);
List<StructField> fields = new ArrayList<StructField>(7);
fields.add(DataTypes.createStructField("a", DataTypes.createDecimalType(), true));
fields.add(DataTypes.createStructField("b", DataTypes.createDecimalType(), true));
sqlContext.applySchema(rows, DataTypes.createStructType(fields)).registerTempTable("foo");
Assert.assertEquals(sqlContext.sql("select * from foo where a > 0").collectAsList(), decimalTable);
}
{code}
Fails with
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to org.apache.spark.sql.types.Decimal
was:
Not quite able to figure this out but here is a junit test to reproduce this,
{code:title=DecimalBug.java}
@Test
public void decimalQueryTest() {
List<Row> decimalTable = new ArrayList<Row>();
decimalTable.add(RowFactory.create(new BigDecimal("1"), new BigDecimal("2")));
decimalTable.add(RowFactory.create(new BigDecimal("3"), new BigDecimal("4")));
JavaRDD<Row> rows = sc.parallelize(decimalTable);
List<StructField> fields = new ArrayList<StructField>(7);
fields.add(DataTypes.createStructField("a", DataTypes.createDecimalType(), true));
fields.add(DataTypes.createStructField("b", DataTypes.createDecimalType(), true));
sqlContext.applySchema(rows, DataTypes.createStructType(fields)).registerTempTable("foo");
Assert.assertEquals(sqlContext.sql("select * from foo where a > 0").collectAsList(), decimalTable);
}
{code}
> Decimal Type comparison issue
> -----------------------------
>
> Key: SPARK-5456
> URL: https://issues.apache.org/jira/browse/SPARK-5456
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 1.2.0
> Reporter: Kuldeep
>
> Not quite able to figure this out but here is a junit test to reproduce this,
> {code:title=DecimalBug.java}
> @Test
> public void decimalQueryTest() {
> List<Row> decimalTable = new ArrayList<Row>();
> decimalTable.add(RowFactory.create(new BigDecimal("1"), new BigDecimal("2")));
> decimalTable.add(RowFactory.create(new BigDecimal("3"), new BigDecimal("4")));
> JavaRDD<Row> rows = sc.parallelize(decimalTable);
> List<StructField> fields = new ArrayList<StructField>(7);
> fields.add(DataTypes.createStructField("a", DataTypes.createDecimalType(), true));
> fields.add(DataTypes.createStructField("b", DataTypes.createDecimalType(), true));
> sqlContext.applySchema(rows, DataTypes.createStructType(fields)).registerTempTable("foo");
> Assert.assertEquals(sqlContext.sql("select * from foo where a > 0").collectAsList(), decimalTable);
> }
> {code}
> Fails with
> java.lang.ClassCastException: java.math.BigDecimal cannot be cast to org.apache.spark.sql.types.Decimal
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org