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

New syntax for creating model from view #379

Open
StpMax opened this issue May 24, 2024 · 5 comments
Open

New syntax for creating model from view #379

StpMax opened this issue May 24, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@StpMax
Copy link
Contributor

StpMax commented May 24, 2024

At the moment creating model from view require a query to the view:

CREATE or replace MODEL model_name
FROM mindsdb (select * from  view)
PREDICT field_name

will be good to be able use mindsdb.view in the query:

CREATE or replace MODEL model_name
FROM mindsdb.view
PREDICT field_name
@StpMax StpMax added the enhancement New feature or request label May 24, 2024
@NikhilDesai27
Copy link

Hi @StpMax ,
I have just started using MindsDB and am eager to help with this.
strategy: Add a new syntax rule to MindsDBParser.create_predictor method, so that it can parse .view segment, expand it to (select * from view) and pass it down to CreatePredictor.
Please advice on the same.
Thanks.

@ea-rus
Copy link
Contributor

ea-rus commented Jun 24, 2024

Yes I think it should create query from table name and then use it as it uses now
For example this query

CREATE my_model FROM mindsdb.my_view PREDICT field_name

Should be converted to

CREATE my_model FROM (select * from mindsdb.my_view) PREDICT field_name

and this

CREATE my_model FROM `my.view` PREDICT field_name

to

CREATE my_model FROM (select * from `my.view`) PREDICT field_name

@NikhilDesai27
Copy link

Hi @ea-rus,
Thanks for clarifying this. I would like to work on it. Please assign it to me.
Thanks,
Nikhil.

@NikhilDesai27
Copy link

Hi @ea-rus,
I need one clarification though. Which of the following SQL statements is right?

  1. CREATE MODEL model_name FROM mindsdb (select * from view) PREDICT field_name
    or,
  2. CREATE MODEL my_model FROM (select * from mindsdb.my_view) PREDICT field_name

I have examined the parsed output of 1, and mindsdb gets passed in as the integration_name and select * from view gets passed in as query_str(raw_query tokens but stringified).
I was planning to go by this, which would result in the following query being parsed in the following way,
query: CREATE MODEL my_model FROM mindsdb.my_view PREDICT field_name
parsed_output: integration_name -> mindsdb, query_str -> "select * from my_view"

Thanks.

@ea-rus
Copy link
Contributor

ea-rus commented Jun 27, 2024

Both statements (1 and 2) are correct (should be parsed and executed)
Yes, I think think it is ok:

query: CREATE MODEL my_model FROM mindsdb.my_view PREDICT field_name
parsed_output: integration_name -> mindsdb, query_str -> "select * from my_view"`

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

No branches or pull requests

3 participants