Skip to content

Commit 75f8739

Browse files
authored
Fix Parquet Provider (#1935)
* Add parquet provider to CI test * Fix parquet get_fields logic
1 parent 22648b1 commit 75f8739

2 files changed

Lines changed: 36 additions & 35 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ jobs:
139139
# pytest tests/test_ogr_wfs_provider_live.py # NOTE: these are skipped in the file but listed here for completeness
140140
pytest tests/test_openapi.py
141141
pytest tests/test_oracle_provider.py
142+
pytest tests/test_parquet_provider.py
142143
pytest tests/test_postgresql_provider.py
143144
pytest tests/test_rasterio_provider.py
144145
pytest tests/test_sensorthings_provider.py

pygeoapi/provider/parquet.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(self, provider_def):
101101
self.ds = pyarrow.dataset.dataset(self.source, filesystem=self.fs)
102102

103103
LOGGER.debug('Grabbing field information')
104-
self.fields = self.get_fields() # Must be set to visualise queryables
104+
self.get_fields() # Must be set to visualise queryables
105105

106106
# Column names for bounding box data.
107107
if None in [self.x_field, self.y_field]:
@@ -148,42 +148,42 @@ def get_fields(self):
148148
:returns: dict of fields
149149
"""
150150

151-
fields = dict()
152-
153-
for field_name, field_type in zip(self.ds.schema.names,
154-
self.ds.schema.types):
155-
# Geometry is managed as a special case by pygeoapi
156-
if field_name == 'geometry':
157-
continue
158-
159-
field_type = str(field_type)
160-
converted_type = None
161-
converted_format = None
162-
if field_type.startswith(('int', 'uint')):
163-
converted_type = 'integer'
164-
converted_format = field_type
165-
elif field_type == 'double' or field_type.startswith('float'):
166-
converted_type = 'number'
167-
converted_format = field_type
168-
elif field_type == 'string':
169-
converted_type = 'string'
170-
elif field_type == 'bool':
171-
converted_type = 'boolean'
172-
elif field_type.startswith('timestamp'):
173-
converted_type = 'string'
174-
converted_format = 'date-time'
175-
else:
176-
LOGGER.error(f'Unsupported field type {field_type}')
151+
if not self._fields:
152+
153+
for field_name, field_type in zip(self.ds.schema.names,
154+
self.ds.schema.types):
155+
# Geometry is managed as a special case by pygeoapi
156+
if field_name == 'geometry':
157+
continue
158+
159+
field_type = str(field_type)
160+
converted_type = None
161+
converted_format = None
162+
if field_type.startswith(('int', 'uint')):
163+
converted_type = 'integer'
164+
converted_format = field_type
165+
elif field_type == 'double' or field_type.startswith('float'):
166+
converted_type = 'number'
167+
converted_format = field_type
168+
elif field_type == 'string':
169+
converted_type = 'string'
170+
elif field_type == 'bool':
171+
converted_type = 'boolean'
172+
elif field_type.startswith('timestamp'):
173+
converted_type = 'string'
174+
converted_format = 'date-time'
175+
else:
176+
LOGGER.error(f'Unsupported field type {field_type}')
177177

178-
if converted_format is None:
179-
fields[field_name] = {'type': converted_type}
180-
else:
181-
fields[field_name] = {
182-
'type': converted_type,
183-
'format': converted_format,
184-
}
178+
if converted_format is None:
179+
self._fields[field_name] = {'type': converted_type}
180+
else:
181+
self._fields[field_name] = {
182+
'type': converted_type,
183+
'format': converted_format,
184+
}
185185

186-
return fields
186+
return self._fields
187187

188188
@crs_transform
189189
def query(

0 commit comments

Comments
 (0)