Skip to content

Commit

Permalink
support time column type
Browse files Browse the repository at this point in the history
  • Loading branch information
thedumbterminal committed Dec 30, 2021
1 parent ee39526 commit d5c59a2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changelog

## v5.0.0 (21/12/2021)
## v5.0.0 (30/12/2021)

* Updated converter to generate numeric instead of float for number type.
* Fixed field name validation.
* Now supports TIME columns.
* Updated to node 16, and updated dependencies.

## v4.1.0 (27/09/2021)

Expand Down
5 changes: 3 additions & 2 deletions src/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const JSON_SCHEMA_TO_BIGQUERY_TYPE_DICT = {
integer: 'INTEGER',
number: 'NUMERIC',
string: 'STRING',
date: 'DATE'
date: 'DATE',
time: 'TIME'
}

const OFS = ['allOf', 'anyOf', 'oneOf']
Expand Down Expand Up @@ -183,7 +184,7 @@ converter._bigQueryType = (node, type) => {
// handle string formats
let actualType = type
const format = node['format']
if(type === 'string' && ['date-time', 'date'].includes(format)){
if(type === 'string' && ['date-time', 'date', 'time'].includes(format)){
actualType = format
}
const bqType = JSON_SCHEMA_TO_BIGQUERY_TYPE_DICT[actualType]
Expand Down
11 changes: 11 additions & 0 deletions test/integration/samples/time/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"schema": {
"fields": [
{
"name": "modified",
"type": "TIME",
"mode": "NULLABLE"
}
]
}
}
12 changes: 12 additions & 0 deletions test/integration/samples/time/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"id": "http://yourdomain.com/schemas/myschema.json",
"description": "Example description",
"type": "object",
"properties": {
"modified": {
"type": "string",
"format": "time"
}
},
"additionalProperties": false
}

0 comments on commit d5c59a2

Please sign in to comment.