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

Update Sqlglot and fix regression #26

Merged
merged 4 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"python.analysis.extraPaths": [
"./defog_utils"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
}
71 changes: 71 additions & 0 deletions tests/test_utils_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,77 @@ def test_mk_create_table_ddl(self):
");\n"
)
self.assertEqual(mk_create_table_ddl(table_name, columns), expected_output)

def test_mk_create_table_ddl_spaces(self):
table_name = "table1"
columns = [
{
"data_type": "text",
"column_name": "Invoice Number",
"column_description": "Unique identifier for each invoice"
},
{
"data_type": "text",
"column_name": "Invoice Date",
"column_description": "Date when the invoice was issued"
},
{
"data_type": "text",
"column_name": "Sales Order#",
"column_description": "Sales order number associated with the invoice"
},
{
"data_type": "text",
"column_name": "Customer Name",
"column_description": "Name of the customer who made the purchase"
},
{
"data_type": "int",
"column_name": "Total with out GST",
"column_description": "Total amount of the invoice without including GST"
},
{
"data_type": "int",
"column_name": "Total",
"column_description": "Total amount of the invoice including GST"
},
{
"data_type": "text",
"column_name": "Status",
"column_description": "Current status of the invoice"
},
{
"data_type": "text",
"column_name": "Salesperson Name",
"column_description": "Name of the salesperson who handled the sale"
},
{
"data_type": "text",
"column_name": "Account Type",
"column_description": "Type of account associated with the invoice"
},
{
"data_type": "text",
"column_name": "Item Category",
"column_description": "Category of the item purchased"
}
]
expected_output = (
"CREATE TABLE table1 (\n"
" \"Invoice Number\" text, --Unique identifier for each invoice\n"
" \"Invoice Date\" text, --Date when the invoice was issued\n"
" \"Sales Order#\" text, --Sales order number associated with the invoice\n"
" \"Customer Name\" text, --Name of the customer who made the purchase\n"
" \"Total with out GST\" integer, --Total amount of the invoice without including GST\n"
" Total integer, --Total amount of the invoice including GST\n"
" Status text, --Current status of the invoice\n"
" \"Salesperson Name\" text, --Name of the salesperson who handled the sale\n"
" \"Account Type\" text, --Type of account associated with the invoice\n"
" \"Item Category\" text --Category of the item purchased\n"
");\n"
)
self.assertEqual(mk_create_table_ddl(table_name, columns), expected_output)



class TestMkCreateDDL(unittest.TestCase):
Expand Down
Loading