Skip to content

Commit

Permalink
Merge pull request #10 from intake/normalize_getitem
Browse files Browse the repository at this point in the history
Normalize source names on catalog access
  • Loading branch information
philippjfr authored Dec 16, 2021
2 parents 0cf1018 + 2e84602 commit 318cbc0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions intake_dremio/dremio_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@ def _load(self):
for _, row in self._dataframe.iterrows():
self._create_entry(row)

def __getitem__(self, key):
normalized_key = key.replace('"', '').lower()
cats = list(self)
normalized_cats = [cat.replace('"', '').lower() for cat in cats]
if key not in cats and normalized_key in normalized_cats:
key = cats[normalized_cats.index(normalized_key)]
return super().__getitem__(key)

def _create_entry(self, row):
name = f'{row.TABLE_SCHEMA}."{row.TABLE_NAME}"'
description = f'Dremio {row.TABLE_TYPE} {name} from {self._source._hostname}'
args = dict(self._source._init_args, sql_expr=f'SELECT * FROM {name}')
e = LocalCatalogEntry(name, description, 'dremio', True,
path = f'"{row.TABLE_SCHEMA}"."{row.TABLE_NAME}"'
description = f'Dremio {row.TABLE_TYPE} {path} from {self._source._hostname}'
args = dict(self._source._init_args, sql_expr=f'SELECT * FROM {path}')
e = LocalCatalogEntry(path, description, 'dremio', True,
args, {}, {}, {}, "", getenv=True,
getshell=False)
e._plugin = [DremioSource]
self._entries[name] = e
self._entries[path] = e

def _repr_html_(self):
(css_style,) = _load_static_files()
Expand Down

0 comments on commit 318cbc0

Please sign in to comment.