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

HCK-8966: RE BigQuery Instance - Display error if dataset is not found #61

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,6 @@
"MODAL_WINDOW___DB_CONNECTIONS_LIST_TITLE": "BigQuery Connections",
"MAIN_MENU___FORWARD_DB_BUCKETS": "BigQuery DDL...",
"MODAL_WINDOW___FE_SCRIPT_OPTION_CREATE": "Create",
"MODAL_WINDOW___FE_SCRIPT_OPTION_UPDATE": "Alter"
"MODAL_WINDOW___FE_SCRIPT_OPTION_UPDATE": "Alter",
"PROJECT_DATASET_NOT_FOUND": "The project or dataset could not be located in the BigQuery instance.\nDouble-check the project id and dataset name. Ensure the necessary permissions are in place to access the project or dataset.\nFor further assistance, please refer to the <a href=\"https://hackolade.com/help/ConnecttoaBigQueryinstance.html\">online documentation</a>."
}
13 changes: 13 additions & 0 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ const testConnection = async (connectionInfo, logger, cb) => {
const bigQueryHelper = createBigQueryHelper(client, log);
await bigQueryHelper.getDatasets();

const datasetName = connectionInfo.datasetId || connectionInfo.data?.databaseName;
if (datasetName) {
await bigQueryHelper.getTables(datasetName);
}

cb();
} catch (err) {
if (err.code === 404) {
err.customMsgCode = 'PROJECT_DATASET_NOT_FOUND';
}
cb(prepareError(logger, err));
}
};
Expand Down Expand Up @@ -92,6 +100,9 @@ const getDbCollectionsNames = async (connectionInfo, logger, cb, app) => {

cb(null, tablesByDataset);
} catch (err) {
if (err.code === 404) {
err.customMsgCode = 'PROJECT_DATASET_NOT_FOUND';
}
cb(prepareError(logger, err));
}
};
Expand Down Expand Up @@ -456,8 +467,10 @@ const getPartitioningRange = rangePartitioning => {

const prepareError = (logger, error) => {
const err = {
code: error.code,
message: error.message,
stack: error.stack,
customMsgCode: error.customMsgCode,
};

logger.log('error', err, 'Reverse Engineering error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
"options": [{ "value": "", "label": "Google Cloud" }]
},
{
"inputLabel": "Project id",
"inputLabel": "Project ID",
"inputKeyword": "projectId",
"inputType": "text",
"inputPlaceholder": "Optional",
"inputTooltip": "Project ID on Google Cloud Platform"
},
{
"inputLabel": "Dataset id",
"inputLabel": "Dataset name",
"inputKeyword": "datasetId",
"inputType": "text",
"inputPlaceholder": "Optional",
"inputTooltip": "Dataset ID on Google Cloud Platform"
"inputTooltip": "Dataset name on Google Cloud Platform"
},
{
"inputLabel": "Key file",
Expand Down
Loading