New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot cast columns to `numeric` on creation #16

kevinushey opened this Issue Jun 9, 2016 · 1 comment


None yet
1 participant

kevinushey commented Jun 9, 2016


> x_tbl <- x_tbl %>% mutate(binary = as.numeric(x > 4))
Error: org.apache.spark.sql.catalyst.parser.ParseException: 
DataType numeric() is not supported.(line 1, pos 103)

== SQL ==
SELECT `carat`, `cut`, `color`, `clarity`, `depth`, `table`, `price`, `x`, `y`, `z`, CAST(`x` > 4.0 AS NUMERIC) AS `binary`
FROM `diamonds`

    at org.apache.spark.sql.catalyst.parser.AstBuilder$$anonfun$visitPrimitiveDataType$1.apply(AstBuilder.scala:1418)
    at org.apache.spark.sql.catalyst.parser.AstBuilder$$anonfun$visitPrimitiveDataType$1.apply(AstBuilder.scala:1400)
    at org.apache.spark.sql.catalyst.parser.ParserUtils$.withOrigin(ParserUtils.scala:89)
    at org.apache.spark.sql.catalyst.parser.AstBuilder.visitPrimitiveDataType(AstBuilder.scala:1399)
    at org.apache.spark.sql.catalyst.parser.AstBuilder.visitPrimitiveDataType(AstBuilder.scala:42)
    at org.apache.spark.sql.catalyst.parser.SqlBaseParser$PrimitiveDataTypeContext.accept( 

That cast probably needs to be DOUBLE, not NUMERIC, but as.double() does not appear to be supported for SQL generation either.


This comment has been minimized.

Show comment
Hide comment

kevinushey Jun 9, 2016


Resolved by amending the sql_translate_env method definition.


kevinushey commented Jun 9, 2016

Resolved by amending the sql_translate_env method definition.

@kevinushey kevinushey closed this Jun 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment