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

Schema refactor #9001

Merged
merged 33 commits into from Apr 26, 2024
Merged

Schema refactor #9001

merged 33 commits into from Apr 26, 2024

Conversation

ea-rus
Copy link
Contributor

@ea-rus ea-rus commented Mar 27, 2024

Description

Changes:

information_schema database

Created information_schema database

  • Tables visible in GUI: MODELS, DATABASES, ML_ENGINES, HANDLERS, JOBS, TRIGGERS, CHATBOTS, KNOWLEDGE_BASES, SKILLS, AGENTS, VIEWS
  • Also information_schema has system tables which are not visible in GUI. But it is possible to select from them because they used by database tools to get database objects, for example: TABLES, SCHEMATA, PLUGINS, ...

image

Syntax update

SHOW:

  • SHOW PROJECTS support
  • SHOW <object> displays objects only from current project
  • To show from other project: SHOW <object> FROM <project name>
  • Also it is possible to filter output:
    • filter by condition show models where engine='openai'
    • filter by name show models like 'home%'

DESCRIBE:

  • Implemented DESCRIBE <object_type> <object_name> command.
    • It works the same as query: select * from informational_schema.<object_type> where name=<object_name>

Update the active model version:

  • was: update models_versions set active=1 where version=11 and name='task_model'
  • will be: Set active task_model.11

Remove the model version:

  • was: delete from models_versions where version=2 and name='task_model'
  • will be: Drop model task_model.2

Changes in project objects

Tables removed from projects (moved to information_schema):

  • models and models_versions: combined into one table information_schema.MODELS
    • it has 'version' column and shows all models versions
  • mdb_triggers. Moved to information_schema.TRIGGERS
    • 'select * from information_schema.triggers' displays different set of columns for sql and http server
      in mysql server columns are extended by system columns required by db tools
  • jobs and chatbots also removed

For back compatibility: it is possible to select from these tables in project (for example select * from mindsdb.models) but this feature be removed in next updates.

Added to projects:

  • Agents are visible in project, because they behave like a model

In action
https://www.loom.com/share/5ac2ce8872384293ba4ea48bc09c2081

Dependent on mindsdb/mindsdb_sql#371

Type of change

  • ⚡ New feature (non-breaking change which adds functionality)
  • 📢 Breaking change (fix or feature that would cause existing functionality not to work as expected)

Verification Process

To ensure the changes are working as expected:

  • Test Location: Specify the URL or path for testing.
  • Verification Steps: Outline the steps or queries needed to validate the change. Include any data, configurations, or actions required to reproduce or see the new functionality.

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

from mindsdb.interfaces.database.projects import ProjectController


from .system_tables import Table
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use absolute imports where possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

data = triggers_controller.get_list(project_name)

columns = self.mindsdb_columns
if inf_schema.session.api_type == 'sql':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need api_type arg only for this specific case?
Is it a good idea to return a different set of columns for each API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, only for this case.
we use the whole set columns for db managers (like dbeaver) and limited set for web GUI, to make able user see only essential information

Also division between system_tables and mindsdb_tables - it is only for SQL server, to make sql clients working. In GUI we show only mindsb tables (though allow to select from all of them)

self.get_dataframe_funcs[table_name] = partial(
self._get_empty_table, table_name
)
self.tables = {t.name: t() for t in self.tables_list}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like tables classes do not use self. May be make them static? so we do not need to instantiate them each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to class_methods

@StpMax
Copy link
Collaborator

StpMax commented Apr 25, 2024

Set model_active = task_model.11 looks strange. In mysql there is few set commands without '=', like
SET CHARACTER SET 'name'
or
SET DEFAULT ROLE admin TO user
May use use something like this?
SET MODEL task_model ACTIVE VERSION TO 11

@ea-rus
Copy link
Contributor Author

ea-rus commented Apr 25, 2024

Set model_active = task_model.11
changed to
Set active task_model.11

CI will be with error till next midsdb_sql release

@ea-rus ea-rus merged commit 3981834 into staging Apr 26, 2024
13 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants