Skip to content

Commit

Permalink
re-enable map key selection even on aliased tables
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerTorres committed Jun 13, 2024
1 parent 8ede171 commit 56c8407
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/queryBuilder/FilterEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export const FilterEditor = (props: {
const { index, filter, allColumns: fieldsList, onFilterChange, removeFilter } = props;
const [isOpen, setIsOpen] = useState(false);
const isMapType = filter.type.startsWith('Map');
const mapKeys = useUniqueMapKeys(props.datasource, (isMapType && !filter.label) ? filter.key : '', props.database, props.table);
const mapKeys = useUniqueMapKeys(props.datasource, isMapType ? filter.key : '', props.database, props.table);
const mapKeyOptions = mapKeys.map(k => ({ label: k, value: k }));
if (filter.mapKey && !mapKeys.includes(filter.mapKey)) {
mapKeyOptions.push({ label: filter.label || filter.mapKey, value: filter.mapKey });
Expand Down Expand Up @@ -375,7 +375,7 @@ export const FilterEditor = (props: {
allowCustomValue
menuPlacement={'bottom'}
/>
{ (isMapType && !filter.label) &&
{ isMapType &&
<Select
value={filter.mapKey}
placeholder={labels.components.FilterEditor.mapKeyPlaceholder}
Expand Down
2 changes: 2 additions & 0 deletions src/data/CHDatasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ export class Datasource
*
* Samples rows to get a unique set of keys for the map.
* May not include ALL keys for a given dataset.
*
* TODO: This query can be slow/expensive
*/
async fetchUniqueMapKeys(mapColumn: string, db: string, table: string): Promise<string[]> {
const rawSql = `SELECT DISTINCT arrayJoin(${mapColumn}.keys) as keys FROM "${db}"."${table}" LIMIT 1000`;
Expand Down

0 comments on commit 56c8407

Please sign in to comment.