Skip to content

Commit

Permalink
feat: Support GEOGRAPHY type field (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
joker1007 committed Dec 16, 2022
1 parent ec62bfa commit 734faa9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integration/fluent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<source>
@type dummy
dummy {"json_field": {"foo": "val1", "bar": "val2", "hoge": 1}, "timestamp_field": "2022-12-15T22:40:21+09:00", "date": "2022-12-15"}
dummy {"json_field": {"foo": "val1", "bar": "val2", "hoge": 1}, "geography_field": {"type": "LineString", "coordinates": [[-118.4085, 33.9416], [-73.7781, 40.6413]]}, "timestamp_field": "2022-12-15T22:40:21+09:00", "date": "2022-12-15", "record_field": {"inner_field": "hoge", "inner_json": {"key1": "val1", "key2": "val2"}}, "repeated_string_field": ["a", "b", "c"]}
auto_increment_key id

tag insert_data
Expand All @@ -29,7 +29,7 @@
total_limit_size 1g
path ./log/bigquery-insert-integration

flush_interval 30
flush_interval 15
flush_thread_count 4
flush_at_shutdown true

Expand Down
10 changes: 10 additions & 0 deletions integration/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"type": "JSON",
"mode": "NULLABLE"
},
{
"name": "geography_field",
"type": "GEOGRAPHY",
"mode": "NULLABLE"
},
{
"name": "timestamp_field",
"type": "TIMESTAMP",
Expand All @@ -33,6 +38,11 @@
"name": "inner_field",
"type": "STRING",
"mode": "REQUIRED"
},
{
"name": "inner_json",
"type": "JSON",
"mode": "REQUIRED"
}
]
},
Expand Down
7 changes: 7 additions & 0 deletions lib/fluent/plugin/bigquery/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def format_one(value, is_load: false)
end
end

class GeographyFieldSchema < StringFieldSchema
def type
:geography
end
end

class IntegerFieldSchema < FieldSchema
def type
:integer
Expand Down Expand Up @@ -200,6 +206,7 @@ class RecordSchema < FieldSchema
datetime: DateTimeFieldSchema,
time: TimeFieldSchema,
json: JsonFieldSchema,
geography: GeographyFieldSchema,
record: RecordSchema
}.freeze

Expand Down

0 comments on commit 734faa9

Please sign in to comment.