Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] handle empty properties in GeoJson file #2381

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/utils/src/dataset-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,12 @@ export function getFieldsFromData(data: RowData, fieldOrder: string[]): Field[]
const name = fieldByIndex[index];

const fieldMeta = metadata.find(m => m.key === field);
let type = fieldMeta.type;
const format = fieldMeta.format;

// fieldMeta could be undefined if the field has no data and Analyzer.computeColMeta
// will dump the field. In this case, we will simply assign the field type to STRING
// since dropping the column in the RowData could be expensive
let type = fieldMeta?.type || 'STRING';
const format = fieldMeta?.format || '';

// check if string is hex wkb
if (type === AnalyzerDATA_TYPES.STRING) {
Expand Down
5 changes: 5 additions & 0 deletions test/node/utils/data-processor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ test('Processor -> getFieldsFromData', t => {
trip_epoch: '1472688000000',
time_str: 'January 1st 2017 11:00pm ',
value: '4',
novalue: null,
surge: '1.2',
isTrip: 'true',
zeroOnes: '0',
Expand All @@ -82,6 +83,7 @@ test('Processor -> getFieldsFromData', t => {
trip_epoch: '1472860800000',
time_str: 'January 1st 2017 11:01pm ',
value: '3',
novalue: null,
surge: null,
isTrip: 'false',
zeroOnes: '1',
Expand All @@ -96,6 +98,7 @@ test('Processor -> getFieldsFromData', t => {
trip_epoch: null,
time_str: 'January 1st, 2017 11:02pm ',
value: '2',
novalue: null,
surge: '1.3',
isTrip: null,
zeroOnes: '1',
Expand All @@ -110,6 +113,7 @@ test('Processor -> getFieldsFromData', t => {
trip_epoch: null,
time_str: 'January 1st, 2017 11:02pm ',
value: '0',
novalue: null,
surge: '1.4',
isTrip: null,
zeroOnes: '0',
Expand All @@ -128,6 +132,7 @@ test('Processor -> getFieldsFromData', t => {
'timestamp',
'timestamp',
'integer',
'string',
'real',
'boolean',
'integer',
Expand Down