sql-machine-learning / jsqlflow

SQLFlow client in Java
Apache License 2.0
7 stars 9 forks source link

Run training and prediction statement error #46

Open DevinKin opened 3 years ago

DevinKin commented 3 years ago

According to the SQLFlowRemoteTest test file, I used Clojure to wrap the test process.

(ns devinkin.sqlflow-remote-cli
  (:import [io.grpc ManagedChannelBuilder]
           [proto Sqlflow])
  (:require
   [devinkin.message-handler-example :as mh]))

(defn get-remote-client
  "get remote client"
  [sqlflow-server sqlflow-submitter sqlflow-data-source user-id message-handler]
  (let [chan (-> (ManagedChannelBuilder/forTarget sqlflow-server)
                 (.usePlaintext)
                 (.build))
        session (-> (proto.Sqlflow$Session/newBuilder)
                    (.setUserId user-id)
                    (.setSubmitter sqlflow-submitter)
                    (.setDbConnStr sqlflow-data-source)
                    (.build))]
    (-> (org.sqlflow.client.SQLFlow$Builder/newInstance)
        (.withSession session)
        (.withIntervalFetching 2000)
        (.withMessageHandler message-handler)
        (.withChannel chan)
        (.build))))

(defn run-remote-test
  [sql]
  (let [client (get-remote-client "192.168.31.102:50051"
                                  "pai"
                                  "mysql://root:root@tcp(192.168.31.102:3306)/iris?maxAllowedPacket=0"
                                  "devin"
                                  (mh/get-message-handler-example))]
    (prn sql)
    (.run client sql)))

;; success
(run-remote-test "SELECT 1")
(run-remote-test "describe iris.train")
(run-remote-test "select * from iris.train limit 5")

;; fail
(run-remote-test "SELECT * FROM iris.train TO TRAIN DNNClassifier WITH  model.n_classes = 3,  model.hidden_units = [10, 10],  train.epoch = 10 COLUMN sepal_length, sepal_width, petal_length, petal_width LABEL class INTO sqlflow_models.my_dnn_model")
(run-remote-test "SELECT * FROM iris.test TO PREDICT iris.predict.class USING sqlflow_models.my_dnn_model")

;; success
(run-remote-test "SELECT * FROM iris.test")
(run-remote-test "SELECT * FROM iris.predict LIMIT 5")

Success

Run normal sql query statements such as

(run-remote-test "SELECT 1")
(run-remote-test "describe iris.train")
(run-remote-test "select * from iris.train limit 5")
(run-remote-test "SELECT * FROM iris.test")
(run-remote-test "SELECT * FROM iris.predict LIMIT 5")

Failure

Run predictions and training statements such as

(run-remote-test "SELECT * FROM iris.train TO TRAIN DNNClassifier WITH  model.n_classes = 3,  model.hidden_units = [10, 10],  train.epoch = 10 COLUMN sepal_length, sepal_width, petal_length, petal_width LABEL class INTO sqlflow_models.my_dnn_model")
(run-remote-test "SELECT * FROM iris.test TO PREDICT iris.predict.class USING sqlflow_models.my_dnn_model")

and got the same error message

1. Unhandled io.grpc.StatusRuntimeException
   UNKNOWN: runSQLProgram error: syntax error near or before
   "sqlflow_models.my_dnn_model". You might want to refer to the
   https://sqlflow.org/sqlflow/doc/language_guide

1. Unhandled io.grpc.StatusRuntimeException
   UNKNOWN: runSQLProgram error: syntax error near or before
   "sqlflow_models.my_dnn_model". You might want to refer to the
   https://sqlflow.org/sqlflow/doc/language_guide

I still don't know why I can't run training and prediction sentences.

Environment

  1. java11
  2. dependency:
    <!-- https://mvnrepository.com/artifact/org.sqlflow/jsqlflow -->
    <dependency>
    <groupId>org.sqlflow</groupId>
    <artifactId>jsqlflow</artifactId>
    <version>0.2.3</version>
    </dependency>
weiguoz commented 3 years ago

Take a try CREATE DATABASE sqlflow_models; before running the two failed statements.

DevinKin commented 3 years ago

I try CREATE DATABASE sqlflow_models; before running the two failed statements

(run-remote-test "DROP DATABASE sqlflow_models")
(run-remote-test "CREATE DATABASE sqlflow_models")
;; fail
(run-remote-test "SELECT * FROM iris.train TO TRAIN DNNClassifier WITH model.n_classes = 3, model.hidden_units = [10, 10], train.epoch = 10 COLUMN sepal_length, sepal_width, petal_length, petal_width LABEL class INTO sqlflow_models.my_dnn_model")
(run-remote-test "SELECT * FROM iris.test TO PREDICT iris.predict.class USING sqlflow_models.my_dnn_model")

and got same error, here is the output

"DROP DATABASE sqlflow_models"
"0 row affected"
"CREATE DATABASE sqlflow_models"
"1 row affected"
"SELECT * FROM iris.train TO TRAIN DNNClassifier WITH model.n_classes = 3, model.hidden_units = [10, 10], train.epoch = 10 COLUMN sepal_length, sepal_width, petal_length, petal_width LABEL class INTO sqlflow_models.my_dnn_model"
Execution error (StatusRuntimeException) at io.grpc.Status/asRuntimeException (Status.java:533).
UNKNOWN: runSQLProgram error: syntax error near or before "sqlflow_models.my_dnn_model". You might want to refer to the https://sqlflow.org/sqlflow/doc/language_guide
"SELECT * FROM iris.test TO PREDICT iris.predict.class USING sqlflow_models.my_dnn_model"
Execution error (StatusRuntimeException) at io.grpc.Status/asRuntimeException (Status.java:533).
UNKNOWN: runSQLProgram error: syntax error near or before "sqlflow_models.my_dnn_model". You might want to refer to the https://sqlflow.org/sqlflow/doc/language_guide