aliyun / aliyun-odps-r-plugin

R plugin for MaxCompute/ODPS
http://odps.aliyun.com
Other
24 stars 6 forks source link

FLOAT数据类型支持BUG #17

Closed icejean closed 3 years ago

icejean commented 3 years ago

library(RODPS)

Sys.setenv(RODPS_CONFIG="D:/odpscmd/conf/odps_config.ini")
Sys.getenv('RODPS_CONFIG')

rodps.set("odps.sql.type.system.odps2","TRUE")
rodps.set("odps.sql.decimal.odps2","TRUE")
rodps.set("odps.sql.hive.compatible","FALSE")
rodps.set("odps.sql.allow.fullscan","true")

rodps.version()
rodps.project.current()

  sql<-"create table if not exists sale_detail
  (
  shop_name     string,
  customer_id   string,
  total_price   float
  ); "
  rodps.table.drop("sale_detail")
  rodps.sql(sql)  
  rodps.table.desc("sale_detail")
  # failed
  # Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  #                   com.aliyun.odps.rodps.DataTunnel.ROdpsException: ODPS-0130071:[1,43] Semantic analysis exception -
  #column __value_col2 in source has incompatible type DOUBLE with destination column total_price, 
  #which has type FLOAT
  rodps.sql("insert into sale_detail values ('ali','1',1000.0);")
  rodps.sql("insert into sale_detail values ('oracle','2',2000.0);")
  #Addressed by setting it with float()
  rodps.sql("insert into sale_detail values ('ali','1',float(3000.0));")
  rodps.sql("insert into sale_detail values ('oracle','2',float(4000.0));")
  temp3<-rodps.sql("select * from sale_detail;")
lyman commented 3 years ago

Not a RODPS issue.

There's no direct way to express a float scalar in SQL. You will have to use cast or float to explicitily indicate its type.

https://help.aliyun.com/document_detail/159540.html

icejean commented 3 years ago

O.K., get it. :)