-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20f980e
commit 9ea8276
Showing
9 changed files
with
569 additions
and
13 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 |
---|---|---|
|
@@ -132,5 +132,4 @@ dist | |
# Minio | ||
minio | ||
fs | ||
tmp | ||
sample | ||
tmp |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,32 @@ | ||
import { expect } from 'chai'; | ||
import { getCsvHeaders } from '../../src/utils/file-validators'; | ||
import { flattenJson, generateDDL } from '../../src/utils/clickhouse'; | ||
|
||
|
||
describe('Create Tables based on files', function () { | ||
this.timeout(60_000); | ||
|
||
it('should extract columns based on a csv file', async () => { | ||
//arrange | ||
const csvFile = Buffer.from('id,name,age\n1,John,20\n2,Jane,21'); | ||
//act | ||
const fields = getCsvHeaders(csvFile); | ||
//assert | ||
expect(fields).to.deep.equal(['id', 'name', 'age']); | ||
}); | ||
|
||
it('should extract columns based on a json file', async () => { | ||
const jsonFile = Buffer.from('[{"id":1,"name":"John","age":20}]'); | ||
const json = JSON.parse(jsonFile.toString()); | ||
const fields = flattenJson(json[0]); | ||
expect(fields).to.deep.equal(['id', 'name', 'age']); | ||
}); | ||
|
||
it('should create a table based on a csv file', async () => { | ||
const csvFile = Buffer.from('id,name,age\n1,John,20\n2,Jane,21'); | ||
const fields = getCsvHeaders(csvFile); | ||
if (!fields) throw new Error('No fields found'); | ||
const result = generateDDL(fields, 'test'); | ||
expect(result).to.equal('CREATE TABLE test (table_id UUID DEFAULT generateUUIDv4(),id VARCHAR, name VARCHAR, age VARCHAR) ENGINE = MergeTree ORDER BY (table_id)'); | ||
}); | ||
}); |