@lightdash/cli 0.3456.0 → 0.3457.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/analytics/analytics.d.ts +2 -0
- package/dist/analytics/analytics.d.ts.map +1 -1
- package/dist/handlers/compile.d.ts +1 -0
- package/dist/handlers/compile.d.ts.map +1 -1
- package/dist/handlers/compile.js +61 -18
- package/dist/handlers/compileWarehouseColumnValidation.test.d.ts +2 -0
- package/dist/handlers/compileWarehouseColumnValidation.test.d.ts.map +1 -0
- package/dist/handlers/compileWarehouseColumnValidation.test.js +441 -0
- package/dist/handlers/validate.d.ts +1 -0
- package/dist/handlers/validate.d.ts.map +1 -1
- package/dist/handlers/validate.js +11 -1
- package/dist/handlers/validate.test.d.ts +2 -0
- package/dist/handlers/validate.test.d.ts.map +1 -0
- package/dist/handlers/validate.test.js +136 -0
- package/dist/index.js +1 -0
- package/package.json +3 -3
|
@@ -15,6 +15,7 @@ type ValidateHandlerOptions = CompileHandlerOptions & {
|
|
|
15
15
|
verbose: boolean;
|
|
16
16
|
preview: boolean;
|
|
17
17
|
only: ValidationTarget[];
|
|
18
|
+
validateWarehouseColumns: boolean;
|
|
18
19
|
showChartConfigurationWarnings: boolean;
|
|
19
20
|
includeSpaces?: string[];
|
|
20
21
|
excludeSpaces?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/handlers/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,OAAO,EACP,YAAY,EAOZ,kBAAkB,EAGlB,gBAAgB,EACnB,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAW,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAS3D,eAAO,MAAM,iBAAiB,GAC1B,aAAa,MAAM,EACnB,UAAU,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EACpC,mBAAmB,gBAAgB,EAAE;;EA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DAKpD,CAAC;AAEP,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAI/B;AAWD,KAAK,sBAAsB,GAAG,qBAAqB,GAAG;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,wBAAwB,EAAE,OAAO,CAAC;IAClC,8BAA8B,EAAE,OAAO,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAYvE,CAAC;AAEF,eAAO,MAAM,eAAe,GACxB,iBAAiB,sBAAsB,kBA2T1C,CAAC"}
|
|
@@ -100,6 +100,7 @@ const validateHandler = async (originalOptions) => {
|
|
|
100
100
|
projectId: projectUuid,
|
|
101
101
|
isPreview,
|
|
102
102
|
validationTargets,
|
|
103
|
+
validateWarehouseColumns: options.validateWarehouseColumns,
|
|
103
104
|
includedSpacesCount: options.includeSpaces?.length ?? 0,
|
|
104
105
|
excludedSpacesCount: options.excludeSpaces?.length ?? 0,
|
|
105
106
|
},
|
|
@@ -117,7 +118,15 @@ const validateHandler = async (originalOptions) => {
|
|
|
117
118
|
selectedSpaceUuids: (0, validateSpaceFilter_1.resolveSpaceSelection)(spaces, spaceFilterSlugs),
|
|
118
119
|
};
|
|
119
120
|
}
|
|
120
|
-
const
|
|
121
|
+
const includesTableValidation = validationTargets.length === 0 ||
|
|
122
|
+
validationTargets.includes(common_1.ValidationTarget.TABLES);
|
|
123
|
+
if (options.validateWarehouseColumns && !includesTableValidation) {
|
|
124
|
+
console.error(styles.warning('> Skipping warehouse column validation because --only does not include the tables validation target'));
|
|
125
|
+
}
|
|
126
|
+
const explores = await (0, compile_1.compile)({
|
|
127
|
+
...options,
|
|
128
|
+
validateWarehouseColumns: options.validateWarehouseColumns && includesTableValidation,
|
|
129
|
+
});
|
|
121
130
|
globalState_1.default.debug(`> Compiled ${explores.length} explores`);
|
|
122
131
|
const validationJob = await (0, exports.requestValidation)(projectUuid, explores, validationTargets);
|
|
123
132
|
const { jobId } = validationJob;
|
|
@@ -148,6 +157,7 @@ const validateHandler = async (originalOptions) => {
|
|
|
148
157
|
projectId: projectUuid,
|
|
149
158
|
isPreview,
|
|
150
159
|
validationTargets,
|
|
160
|
+
validateWarehouseColumns: options.validateWarehouseColumns,
|
|
151
161
|
includedSpacesCount: options.includeSpaces?.length ?? 0,
|
|
152
162
|
excludedSpacesCount: options.excludeSpaces?.length ?? 0,
|
|
153
163
|
durationMs: Date.now() - startTime,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.test.d.ts","sourceRoot":"","sources":["../../src/handlers/validate.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@lightdash/common");
|
|
4
|
+
const compile_1 = require("./compile");
|
|
5
|
+
const apiClient_1 = require("./dbt/apiClient");
|
|
6
|
+
const validate_1 = require("./validate");
|
|
7
|
+
vi.mock('../analytics/analytics');
|
|
8
|
+
vi.mock('../config', () => ({
|
|
9
|
+
getConfig: vi.fn().mockResolvedValue({ user: null, context: null }),
|
|
10
|
+
}));
|
|
11
|
+
vi.mock('./compile');
|
|
12
|
+
vi.mock('./dbt/apiClient');
|
|
13
|
+
vi.mock('./timestampConversion');
|
|
14
|
+
const baseOptions = {
|
|
15
|
+
project: 'test-project-uuid',
|
|
16
|
+
preview: false,
|
|
17
|
+
only: Object.values(common_1.ValidationTarget),
|
|
18
|
+
validateWarehouseColumns: false,
|
|
19
|
+
showChartConfigurationWarnings: false,
|
|
20
|
+
projectDir: '.',
|
|
21
|
+
profilesDir: '.',
|
|
22
|
+
target: undefined,
|
|
23
|
+
profile: undefined,
|
|
24
|
+
vars: undefined,
|
|
25
|
+
verbose: false,
|
|
26
|
+
startOfWeek: 0,
|
|
27
|
+
skipWarehouseCatalog: undefined,
|
|
28
|
+
skipDbtCompile: true,
|
|
29
|
+
useDbtList: false,
|
|
30
|
+
select: undefined,
|
|
31
|
+
models: undefined,
|
|
32
|
+
threads: undefined,
|
|
33
|
+
noVersionCheck: false,
|
|
34
|
+
exclude: undefined,
|
|
35
|
+
selector: undefined,
|
|
36
|
+
state: undefined,
|
|
37
|
+
fullRefresh: false,
|
|
38
|
+
defer: false,
|
|
39
|
+
targetPath: undefined,
|
|
40
|
+
favorState: false,
|
|
41
|
+
combineManifest: undefined,
|
|
42
|
+
warehouseCredentials: false,
|
|
43
|
+
disableTimestampConversion: false,
|
|
44
|
+
};
|
|
45
|
+
const TARGET_SKIP_WARNING = 'Skipping warehouse column validation because --only does not include the tables validation target';
|
|
46
|
+
describe('validateHandler warehouse column validation', () => {
|
|
47
|
+
let errorOutput;
|
|
48
|
+
const skipWarnings = () => errorOutput.filter((line) => line.includes('Skipping warehouse column validation'));
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
vi.clearAllMocks();
|
|
51
|
+
vi.mocked(apiClient_1.checkLightdashVersion).mockResolvedValue(undefined);
|
|
52
|
+
vi.mocked(compile_1.compile).mockResolvedValue([]);
|
|
53
|
+
vi.mocked(apiClient_1.lightdashApi).mockImplementation(async ({ method, url }) => {
|
|
54
|
+
if (method === 'POST' && url.endsWith('/validate')) {
|
|
55
|
+
return { jobId: 'test-job-id' };
|
|
56
|
+
}
|
|
57
|
+
if (url.includes('/schedulers/job/')) {
|
|
58
|
+
return { status: common_1.SchedulerJobStatus.COMPLETED, details: null };
|
|
59
|
+
}
|
|
60
|
+
if (url.includes('/validate?jobId=')) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Unexpected API call: ${method} ${url}`);
|
|
64
|
+
});
|
|
65
|
+
errorOutput = [];
|
|
66
|
+
vi.spyOn(console, 'error').mockImplementation((...args) => {
|
|
67
|
+
errorOutput.push(args.map(String).join(' '));
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
afterEach(() => {
|
|
71
|
+
vi.restoreAllMocks();
|
|
72
|
+
});
|
|
73
|
+
test('does not request warehouse column validation by default', async () => {
|
|
74
|
+
await (0, validate_1.validateHandler)({ ...baseOptions });
|
|
75
|
+
expect(compile_1.compile).toHaveBeenCalledTimes(1);
|
|
76
|
+
expect(compile_1.compile).toHaveBeenCalledWith(expect.objectContaining({ validateWarehouseColumns: false }));
|
|
77
|
+
expect(skipWarnings()).toEqual([]);
|
|
78
|
+
});
|
|
79
|
+
test('requests warehouse column validation when the flag is set and every target is validated', async () => {
|
|
80
|
+
await (0, validate_1.validateHandler)({
|
|
81
|
+
...baseOptions,
|
|
82
|
+
validateWarehouseColumns: true,
|
|
83
|
+
});
|
|
84
|
+
expect(compile_1.compile).toHaveBeenCalledWith(expect.objectContaining({ validateWarehouseColumns: true }));
|
|
85
|
+
expect(skipWarnings()).toEqual([]);
|
|
86
|
+
});
|
|
87
|
+
test('requests warehouse column validation when the flag is set and only tables are validated', async () => {
|
|
88
|
+
await (0, validate_1.validateHandler)({
|
|
89
|
+
...baseOptions,
|
|
90
|
+
only: [common_1.ValidationTarget.TABLES],
|
|
91
|
+
validateWarehouseColumns: true,
|
|
92
|
+
});
|
|
93
|
+
expect(compile_1.compile).toHaveBeenCalledWith(expect.objectContaining({ validateWarehouseColumns: true }));
|
|
94
|
+
expect(skipWarnings()).toEqual([]);
|
|
95
|
+
});
|
|
96
|
+
test('requests warehouse column validation when the flag is set and a mixed target list includes tables', async () => {
|
|
97
|
+
await (0, validate_1.validateHandler)({
|
|
98
|
+
...baseOptions,
|
|
99
|
+
only: [common_1.ValidationTarget.TABLES, common_1.ValidationTarget.CHARTS],
|
|
100
|
+
validateWarehouseColumns: true,
|
|
101
|
+
});
|
|
102
|
+
expect(compile_1.compile).toHaveBeenCalledWith(expect.objectContaining({ validateWarehouseColumns: true }));
|
|
103
|
+
expect(skipWarnings()).toEqual([]);
|
|
104
|
+
});
|
|
105
|
+
test('does not request warehouse column validation when tables are not validated', async () => {
|
|
106
|
+
await (0, validate_1.validateHandler)({
|
|
107
|
+
...baseOptions,
|
|
108
|
+
only: [common_1.ValidationTarget.CHARTS, common_1.ValidationTarget.DASHBOARDS],
|
|
109
|
+
validateWarehouseColumns: true,
|
|
110
|
+
});
|
|
111
|
+
expect(compile_1.compile).toHaveBeenCalledWith(expect.objectContaining({ validateWarehouseColumns: false }));
|
|
112
|
+
const warnings = skipWarnings();
|
|
113
|
+
expect(warnings).toHaveLength(1);
|
|
114
|
+
expect(warnings[0]).toContain(TARGET_SKIP_WARNING);
|
|
115
|
+
});
|
|
116
|
+
test('warns exactly once when the flag is set and only charts are validated', async () => {
|
|
117
|
+
await (0, validate_1.validateHandler)({
|
|
118
|
+
...baseOptions,
|
|
119
|
+
only: [common_1.ValidationTarget.CHARTS],
|
|
120
|
+
validateWarehouseColumns: true,
|
|
121
|
+
});
|
|
122
|
+
expect(compile_1.compile).toHaveBeenCalledWith(expect.objectContaining({ validateWarehouseColumns: false }));
|
|
123
|
+
const warnings = skipWarnings();
|
|
124
|
+
expect(warnings).toHaveLength(1);
|
|
125
|
+
expect(warnings[0]).toContain(TARGET_SKIP_WARNING);
|
|
126
|
+
});
|
|
127
|
+
test('does not warn when only charts are validated without the flag', async () => {
|
|
128
|
+
await (0, validate_1.validateHandler)({
|
|
129
|
+
...baseOptions,
|
|
130
|
+
only: [common_1.ValidationTarget.CHARTS],
|
|
131
|
+
validateWarehouseColumns: false,
|
|
132
|
+
});
|
|
133
|
+
expect(compile_1.compile).toHaveBeenCalledWith(expect.objectContaining({ validateWarehouseColumns: false }));
|
|
134
|
+
expect(skipWarnings()).toEqual([]);
|
|
135
|
+
});
|
|
136
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -481,6 +481,7 @@ commander_1.program
|
|
|
481
481
|
.addOption(new commander_1.Option('--only <elems...>', 'Specify project elements to validate')
|
|
482
482
|
.choices(Object.values(common_1.ValidationTarget))
|
|
483
483
|
.default(Object.values(common_1.ValidationTarget)))
|
|
484
|
+
.option('--validate-warehouse-columns', `Check physical \${TABLE}.column references in dimensions and metrics by executing zero-row queries against the warehouse. Requires warehouse credentials and only applies when tables are validated.`, false)
|
|
484
485
|
.option('--include-spaces <spaceSlugs...>', 'Only report validation errors for charts and dashboards in these spaces (and their sub-spaces). Spaces must be visible to your credentials')
|
|
485
486
|
.option('--exclude-spaces <spaceSlugs...>', 'Skip validation errors for charts and dashboards in these spaces (and their sub-spaces). Spaces must be visible to your credentials')
|
|
486
487
|
.action(validate_1.validateHandler);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3457.0",
|
|
4
4
|
"description": "Lightdash CLI tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"unique-names-generator": "4.7.1",
|
|
42
42
|
"uuid": "11.1.1",
|
|
43
43
|
"yaml": "2.8.3",
|
|
44
|
-
"@lightdash/common": "0.
|
|
45
|
-
"@lightdash/warehouses": "0.
|
|
44
|
+
"@lightdash/common": "0.3457.0",
|
|
45
|
+
"@lightdash/warehouses": "0.3457.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/inquirer": "8.2.4",
|