-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dremio-driver): add basic integration tests for dremio cloud (#…
- Loading branch information
Showing
9 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
# Debug log for test containers | ||
export DEBUG=testcontainers | ||
|
||
echo "::group::Dremio [cloud]" | ||
yarn lerna run --concurrency 1 --stream --no-prefix integration:dremio | ||
|
||
echo "::endgroup::" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { DriverTests } from '@cubejs-backend/testing-shared'; | ||
|
||
const DremioDriver = require('../../driver/DremioDriver'); | ||
|
||
describe('DremioDriver', () => { | ||
let tests: DriverTests; | ||
|
||
jest.setTimeout(10 * 60 * 1000); // Engine needs to spin up | ||
|
||
beforeAll(async () => { | ||
tests = new DriverTests(new DremioDriver({}), { expectStringFields: false }); | ||
}); | ||
|
||
afterAll(async () => { | ||
await tests.release(); | ||
}); | ||
|
||
test('query', async () => { | ||
await tests.testQuery(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { prepareCompiler as originalPrepareCompiler } from '@cubejs-backend/schema-compiler'; | ||
|
||
const DremioQuery = require('../../driver/DremioQuery'); | ||
|
||
const prepareCompiler = (content: string) => originalPrepareCompiler({ | ||
localPath: () => __dirname, | ||
dataSchemaFiles: () => Promise.resolve([{ fileName: 'main.js', content }]), | ||
}); | ||
|
||
describe('DremioQuery', () => { | ||
|
||
jest.setTimeout(10 * 60 * 1000); // Engine needs to spin up | ||
|
||
const { compiler, joinGraph, cubeEvaluator } = prepareCompiler( | ||
` | ||
cube(\`sales\`, { | ||
sql: \` select * from public.sales \`, | ||
measures: { | ||
count: { | ||
type: 'count' | ||
} | ||
}, | ||
dimensions: { | ||
category: { | ||
type: 'string', | ||
sql: 'category' | ||
}, | ||
salesDatetime: { | ||
type: 'time', | ||
sql: 'sales_datetime' | ||
}, | ||
isShiped: { | ||
type: 'boolean', | ||
sql: 'is_shiped', | ||
}, | ||
} | ||
}); | ||
`, | ||
); | ||
|
||
it('should use DATE_TRUNC for time granularity dimensions', () => compiler.compile().then(() => { | ||
const query = new DremioQuery( | ||
{ joinGraph, cubeEvaluator, compiler }, | ||
{ | ||
measures: ['sales.count'], | ||
timeDimensions: [ | ||
{ | ||
dimension: 'sales.salesDatetime', | ||
granularity: 'day', | ||
dateRange: ['2017-01-01', '2017-01-02'], | ||
}, | ||
], | ||
timezone: 'America/Los_Angeles', | ||
order: [ | ||
{ | ||
id: 'sales.salesDatetime', | ||
}, | ||
], | ||
} | ||
); | ||
|
||
const queryAndParams = query.buildSqlAndParams(); | ||
|
||
expect(queryAndParams[0]).toContain( | ||
'DATE_TRUNC(\'day\', CONVERT_TIMEZONE(\'-08:00\', "sales".sales_datetime))' | ||
); | ||
})); | ||
|
||
it('should cast BOOLEAN', () => compiler.compile().then(() => { | ||
const query = new DremioQuery( | ||
{ joinGraph, cubeEvaluator, compiler }, | ||
{ | ||
measures: ['sales.count'], | ||
filters: [ | ||
{ | ||
member: 'sales.isShiped', | ||
operator: 'equals', | ||
values: ['true'] | ||
} | ||
] | ||
} | ||
); | ||
|
||
const queryAndParams = query.buildSqlAndParams(); | ||
|
||
expect(queryAndParams[0]).toContain( | ||
'("sales".is_shiped = CAST(? AS BOOLEAN))' | ||
); | ||
|
||
expect(queryAndParams[1]).toEqual(['true']); | ||
})); | ||
|
||
it('should cast timestamp', () => compiler.compile().then(() => { | ||
const query = new DremioQuery( | ||
{ joinGraph, cubeEvaluator, compiler }, | ||
{ | ||
measures: ['sales.count'], | ||
timeDimensions: [ | ||
{ | ||
dimension: 'sales.salesDatetime', | ||
granularity: 'day', | ||
dateRange: ['2017-01-01', '2017-01-02'], | ||
}, | ||
], | ||
timezone: 'America/Los_Angeles', | ||
order: [ | ||
{ | ||
id: 'sales.salesDatetime', | ||
}, | ||
], | ||
} | ||
); | ||
|
||
const queryAndParams = query.buildSqlAndParams(); | ||
|
||
expect(queryAndParams[0]).toContain( | ||
'("sales".sales_datetime >= TO_TIMESTAMP(?, \'YYYY-MM-DD"T"HH24:MI:SS.FFF\') AND "sales".sales_datetime <= TO_TIMESTAMP(?, \'YYYY-MM-DD"T"HH24:MI:SS.FFF\'))' | ||
); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const REQUIRED_ENV_VARS = [ | ||
'CUBEJS_DB_URL', | ||
'CUBEJS_DB_NAME', | ||
'CUBEJS_DB_DREMIO_AUTH_TOKEN', | ||
]; | ||
|
||
REQUIRED_ENV_VARS.forEach((key) => { | ||
// Trying to populate from DRIVERS_TESTS_DREMIO_* vars | ||
if (process.env[`DRIVERS_TESTS_DREMIO_${key}`] !== undefined) { | ||
process.env[key] = process.env[`DRIVERS_TESTS_DREMIO_${key}`]; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": [ | ||
"src", | ||
"test" | ||
], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": ".", | ||
"baseUrl": ".", | ||
"resolveJsonModule": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters