mindsdb / mindsdb_sql

SQL parser and planner used by MindsDB
https://mindsdb.com
GNU General Public License v3.0
55 stars 21 forks source link

Fail to parse complex query when creating job #308

Closed yuhuishi-convect closed 1 year ago

yuhuishi-convect commented 1 year ago

The parser failed to parse the following create job query

CREATE JOB (
  INSERT INTO chroma_dev_local.mindsdb_issue_index
  (
    SELECT gh.id, gh.content, m.embeddings 
    FROM (
      SELECT 'issue' || number as id, concat_ws('\n\n', title, body) as content
      FROM (
        SELECT number, state, creator, assignee, title, body, labels
        FROM mindsdb_github.issues
        WHERE state="all"
        AND 
          created > '{{ PREVIOUS_START_DATETIME  }}'
        ORDER BY created DESC
        LIMIT 50
      )
    ) as gh
    JOIN
    openai_embedding_model as m
  )
)
EVERY HOUR;

But the inner query is valid and can be parsed correctly

INSERT INTO chroma_dev_local.mindsdb_issue_index
  (
    SELECT gh.id, gh.content, m.embeddings 
    FROM (
      SELECT 'issue' || number as id, concat_ws('\n\n', title, body) as content
      FROM (
        SELECT number, state, creator, assignee, title, body, labels
        FROM mindsdb_github.issues
        WHERE state="all"
        AND 
          created > '{{ PREVIOUS_START_DATETIME  }}'
        ORDER BY created DESC
        LIMIT 50
      )
    ) as gh
    JOIN
    openai_embedding_model as m
  )
ea-rus commented 1 year ago

CREATE JOB command must content name:

CREATE JOB my_job1 (
   ...
)
....
yuhuishi-convect commented 1 year ago

Sorry my bad. closing