OpenMLDB icon indicating copy to clipboard operation
OpenMLDB copied to clipboard

cast string as date not support in offline

Open lqy222 opened this issue 1 year ago • 2 comments

select date("2020-05-22"); below SQL not support in offline mode

lqy222 avatar Dec 29 '23 08:12 lqy222

It is caused by not handling ExprType.kExprCast in ConstProjectPlan.

tobegit3hub avatar Jan 23 '24 09:01 tobegit3hub

Since the offline output does not consist of column data, we need to fix the output of ConstProjectPlan first. Otherwise we can only get the output column name date("2020-05-22") but no exactly data.

+----------------+
|date(2020-05-22)|
+----------------+
+----------------+

Here is the simple code to reproduce the issue.

import com._4paradigm.openmldb.batch.SparkTestSuite
import com._4paradigm.openmldb.batch.api.OpenmldbSession
import com._4paradigm.openmldb.batch.end2end.DataUtil
import com._4paradigm.openmldb.batch.utils.SparkUtil


class TestProject extends SparkTestSuite {

  test("Test end2end window aggregation") {

    val spark = getSparkSession
    val sess = new OpenmldbSession(spark)

    val df = DataUtil.getTestDf(spark)

    sess.registerTable("t1", df)
    df.createOrReplaceTempView("t1")

    val sql2 = "SELECT date('2024-01-01') FROM t1"
    val sql3 = "select int(1.1)"
    val sql = "select date('2020-05-22')"

    val outputDf = sess.sql(sql)
    outputDf.show()
  }

}

tobegit3hub avatar Jan 23 '24 09:01 tobegit3hub