mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
feat(dbc ui): Adding Google Sheets Dynamic Form (#15801)
* feat: Make Google Sheets Dyanmic (#15576) * first draft * second draft * added tests * first draft * added table_catalog * remove console.log * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * revisions * save this for now * working form * save disable on public sheets * refactor somethings * saving this for now * working edit * add back query to schema * working add * fix styling * fixing x * fix linting * prettier * fix some type issues * more lint fixes * remove unused dependency * fix linint * fix validation * pylint bypass * pylint bypass * fix this * fix mypy * yerp * fix test * fix test * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * wrap add sheets * fix linting issues * fix unit test * ignore typing * fix editting and paste issues * remove query * fix this * fix test * add test back * fix error messaging * update url messaging on error * change error type * Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * add errors for sheets with no name * fix * fix messaging for gsheets * stop pylint * update line Co-authored-by: AAfghahi <48933336+AAfghahi@users.noreply.github.com> Co-authored-by: Arash <arash.afghahi@gmail.com> Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
This commit is contained in:
@@ -37,11 +37,27 @@ def test_validate_parameters_simple(
|
||||
|
||||
parameters: GSheetsParametersType = {
|
||||
"credentials_info": {},
|
||||
"query": {},
|
||||
"table_catalog": {},
|
||||
"catalog": {},
|
||||
}
|
||||
errors = GSheetsEngineSpec.validate_parameters(parameters)
|
||||
assert errors == []
|
||||
assert errors == [
|
||||
SupersetError(
|
||||
message="URL is required",
|
||||
error_type=SupersetErrorType.CONNECTION_MISSING_PARAMETERS_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"invalid": ["catalog"],
|
||||
"name": "",
|
||||
"url": "",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1018,
|
||||
"message": "Issue 1018 - One or more parameters needed to configure a database are missing.",
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def test_validate_parameters_catalog(
|
||||
@@ -66,72 +82,57 @@ def test_validate_parameters_catalog(
|
||||
|
||||
parameters: GSheetsParametersType = {
|
||||
"credentials_info": {},
|
||||
"query": {},
|
||||
"table_catalog": {
|
||||
"catalog": {
|
||||
"private_sheet": "https://docs.google.com/spreadsheets/d/1/edit",
|
||||
"public_sheet": "https://docs.google.com/spreadsheets/d/1/edit#gid=1",
|
||||
"not_a_sheet": "https://www.google.com/",
|
||||
},
|
||||
}
|
||||
errors = GSheetsEngineSpec.validate_parameters(parameters)
|
||||
errors = GSheetsEngineSpec.validate_parameters(parameters) # ignore: type
|
||||
|
||||
assert errors == [
|
||||
SupersetError(
|
||||
message=(
|
||||
"Unable to connect to spreadsheet private_sheet at "
|
||||
"https://docs.google.com/spreadsheets/d/1/edit"
|
||||
),
|
||||
message="URL could not be identified",
|
||||
error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"invalid": ["catalog"],
|
||||
"name": "private_sheet",
|
||||
"url": "https://docs.google.com/spreadsheets/d/1/edit",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1003,
|
||||
"message": (
|
||||
"Issue 1003 - There is a syntax error in the SQL query. "
|
||||
"Perhaps there was a misspelling or a typo."
|
||||
),
|
||||
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.",
|
||||
},
|
||||
{
|
||||
"code": 1005,
|
||||
"message": (
|
||||
"Issue 1005 - The table was deleted or renamed in the "
|
||||
"database."
|
||||
),
|
||||
"message": "Issue 1005 - The table was deleted or renamed in the database.",
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
SupersetError(
|
||||
message=(
|
||||
"Unable to connect to spreadsheet not_a_sheet at "
|
||||
"https://www.google.com/"
|
||||
),
|
||||
message="URL could not be identified",
|
||||
error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"invalid": ["catalog"],
|
||||
"name": "not_a_sheet",
|
||||
"url": "https://www.google.com/",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1003,
|
||||
"message": (
|
||||
"Issue 1003 - There is a syntax error in the SQL query. "
|
||||
"Perhaps there was a misspelling or a typo."
|
||||
),
|
||||
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.",
|
||||
},
|
||||
{
|
||||
"code": 1005,
|
||||
"message": (
|
||||
"Issue 1005 - The table was deleted or renamed in the "
|
||||
"database.",
|
||||
),
|
||||
"message": "Issue 1005 - The table was deleted or renamed in the database.",
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
create_engine.assert_called_with(
|
||||
"gsheets://", service_account_info={}, subject="admin@example.com",
|
||||
)
|
||||
@@ -159,44 +160,36 @@ def test_validate_parameters_catalog_and_credentials(
|
||||
|
||||
parameters: GSheetsParametersType = {
|
||||
"credentials_info": {},
|
||||
"query": {},
|
||||
"table_catalog": {
|
||||
"catalog": {
|
||||
"private_sheet": "https://docs.google.com/spreadsheets/d/1/edit",
|
||||
"public_sheet": "https://docs.google.com/spreadsheets/d/1/edit#gid=1",
|
||||
"not_a_sheet": "https://www.google.com/",
|
||||
},
|
||||
}
|
||||
errors = GSheetsEngineSpec.validate_parameters(parameters)
|
||||
errors = GSheetsEngineSpec.validate_parameters(parameters) # ignore: type
|
||||
assert errors == [
|
||||
SupersetError(
|
||||
message=(
|
||||
"Unable to connect to spreadsheet not_a_sheet at "
|
||||
"https://www.google.com/"
|
||||
),
|
||||
message="URL could not be identified",
|
||||
error_type=SupersetErrorType.TABLE_DOES_NOT_EXIST_ERROR,
|
||||
level=ErrorLevel.WARNING,
|
||||
extra={
|
||||
"invalid": ["catalog"],
|
||||
"name": "not_a_sheet",
|
||||
"url": "https://www.google.com/",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1003,
|
||||
"message": (
|
||||
"Issue 1003 - There is a syntax error in the SQL query. "
|
||||
"Perhaps there was a misspelling or a typo."
|
||||
),
|
||||
"message": "Issue 1003 - There is a syntax error in the SQL query. Perhaps there was a misspelling or a typo.",
|
||||
},
|
||||
{
|
||||
"code": 1005,
|
||||
"message": (
|
||||
"Issue 1005 - The table was deleted or renamed in the "
|
||||
"database.",
|
||||
),
|
||||
"message": "Issue 1005 - The table was deleted or renamed in the database.",
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
)
|
||||
]
|
||||
|
||||
create_engine.assert_called_with(
|
||||
"gsheets://", service_account_info={}, subject="admin@example.com",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user