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

'Create table' syntax improvement #395

Merged
merged 3 commits into from
Aug 30, 2024
Merged

'Create table' syntax improvement #395

merged 3 commits into from
Aug 30, 2024

Conversation

ea-rus
Copy link
Contributor

@ea-rus ea-rus commented Aug 29, 2024

Updates:
1. support primary keys
Serial

CREATE TABLE tbl1(
    person_id serial,
    ...
)

Primary key column:

CREATE TABLE tbl1(
    person_id INT  PRIMARY KEY,
    ...
)

Multiple columns as primary key

CREATE TABLE tbl1(
    person_id INT,
    location_id INT
    ...
    PRIMARY KEY (person_id, location_id)
)

2. support nullable

CREATE TABLE tbl1(
    ...
    name TEXT null -- or 'not null'
)

3. support default value

CREATE TABLE tbl1(
    ...
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP  
)

ea-rus added 3 commits August 29, 2024 12:28
used to be: list of expressions
1. support primary keys
- serial
- "col type primary key"
- "primary key (col1, col2)"

2. support nullable
3. support default value
Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
mindsdb_sql
   __about__.py10100%1–10
   __init__.py1292283%43, 47, 93, 110, 134–153, 160–161, 178
mindsdb_sql/parser
   lexer.py165199%243
   logger.py19479%14, 17, 23, 26
   parser.py4563193%48, 53, 73, 77, 81, 87, 91–93, 121–128, 182, 199, 249, 253, 317, 346–347, 367, 378, 491, 526, 557, 567, 581, 657
   utils.py46491%73–79
mindsdb_sql/parser/ast
   base.py36781%13, 28, 31, 49–52
   create.py761087%7–8, 23, 28, 91–96
   drop.py52296%10, 13
   insert.py63494%39–41, 46
   show.py48198%18
   update.py53591%40–42, 75–76
mindsdb_sql/parser/ast/select
   case.py26292%19, 22
   constant.py36197%23
   data.py11282%15, 19
   identifier.py64789%43, 80–85
   native_query.py13192%25
   operation.py131497%56, 65, 168, 187
   parameter.py11191%10
   select.py97397%148–153
   star.py12283%8–9
   union.py23196%18
mindsdb_sql/parser/dialects/mindsdb
   knowledge_base.py46198%79
   lexer.py2622192%343, 345, 347, 359, 361, 363, 369–387
   parser.py10142697%119, 123, 262, 287, 384, 570, 587, 611–612, 808, 862, 939, 1068, 1078, 1116–1117, 1142, 1153, 1235, 1298, 1358, 1826, 1834, 1887–1890
mindsdb_sql/parser/dialects/mysql
   lexer.py23674%16, 18, 20, 32, 34, 36
   parser.py6092496%131, 133, 226–227, 326, 356, 373, 423, 427, 501, 511, 549–550, 570, 581, 702, 730, 735–737, 741, 758, 902, 1046
   show_index.py171135%10–12, 15–23, 26–27
mindsdb_sql/planner
   plan_join.py3221396%141, 179, 188, 215, 219, 308, 358, 376, 385–386, 435, 445, 447
   plan_join_ts.py1791094%53, 60, 83–84, 129, 181, 185, 193, 268, 335
   query_plan.py22864%13–21, 30
   query_planner.py4146784%41–42, 65–66, 75, 166, 309, 327–329, 336, 437, 465–543, 586–587, 600, 626, 688, 718, 746, 771–773
   query_prepare.py2846179%76, 78, 86–116, 227, 249, 272, 315, 336, 360, 389–443, 446–452, 483, 496–498, 507, 526
   step_result.py14286%7, 12
   steps.py1581690%12, 17, 25, 30–32, 51–53, 61–64, 90–92
   ts_utils.py67691%59, 61, 83–86, 90
   utils.py2422789%60, 106, 112, 127, 139, 151, 154, 166, 194, 207, 222, 228, 233, 240, 242, 247, 260, 265, 271, 277, 291, 308, 338–339, 350–351, 366
mindsdb_sql/render
   sqlalchemy_render.py4478082%53, 88, 90, 102, 107, 124, 126, 128, 130, 192, 195–196, 209–210, 221–222, 240, 270, 272, 307, 321, 327, 378, 441–452, 463–467, 497, 512, 517–527, 536–537, 539–540, 547, 570–581, 601, 634–658, 681, 687, 727–730, 751–754
TOTAL655450492% 

Tests Skipped Failures Errors Time
680 1 💤 0 ❌ 0 🔥 24.864s ⏱️

@ea-rus ea-rus merged commit 9aa6784 into staging Aug 30, 2024
7 checks passed
@ea-rus ea-rus mentioned this pull request Sep 2, 2024
@ea-rus ea-rus deleted the create-table branch October 31, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: merged
Development

Successfully merging this pull request may close these issues.

1 participant