Skip to content
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

Run training and prediction statement error #46

Open
DevinKin opened this issue Apr 26, 2021 · 2 comments
Open

Run training and prediction statement error #46

DevinKin opened this issue Apr 26, 2021 · 2 comments

Comments

@DevinKin
Copy link

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
Copy link
Collaborator

weiguoz commented Apr 27, 2021

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

@DevinKin
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants