Skip to content
Snippets Groups Projects
Unverified Commit e4a16b9a authored by dpsutton's avatar dpsutton Committed by GitHub
Browse files

Look at effective-type in the UI (#15213)

* Look at effective-type in the UI

still want to fall back to base_type if effective_type is not
present. Our inference doesn't set effective_type at the moment as
this change was super invasive and led to conflicts to other refactors
at the time. In the future almost nothing except for query processors
should care about base_type and only look at the (required)
effective_type.

* Check base and semantic (not base and effective) when no effective_type

* Correct typo in isNumericBaseType

was incorrectly checking effective_type instead of either effective or base
parent 826537b1
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ export type Field = {
display_name: string,
description: string,
base_type: BaseType,
effective_type?: BaseType,
semantic_type: SemanticType,
active: boolean,
visibility_type: FieldVisibilityType,
......
......@@ -31,21 +31,26 @@ export const UNKNOWN = "UNKNOWN";
const TYPES = {
[TEMPORAL]: {
base: [TYPE.Temporal],
effective: [TYPE.Temporal],
semantic: [TYPE.Temporal],
},
[NUMBER]: {
base: [TYPE.Number],
effective: [TYPE.Number],
semantic: [TYPE.Number],
},
[STRING]: {
base: [TYPE.Text],
effective: [TYPE.Text],
semantic: [TYPE.Text],
},
[STRING_LIKE]: {
base: [TYPE.TextLike],
effective: [TYPE.TextLike],
},
[BOOLEAN]: {
base: [TYPE.Boolean],
effective: [TYPE.Boolean],
},
[COORDINATE]: {
semantic: [TYPE.Coordinate],
......@@ -68,6 +73,7 @@ const TYPES = {
},
[CATEGORY]: {
base: [TYPE.Boolean],
effective: [TYPE.Boolean],
semantic: [TYPE.Category],
include: [LOCATION],
},
......@@ -84,7 +90,10 @@ export function isFieldType(type, field) {
const typeDefinition = TYPES[type];
// check to see if it belongs to any of the field types:
for (const prop of ["base", "semantic"]) {
const props = field.effective_type
? ["effective", "semantic"]
: ["base", "semantic"];
for (const prop of props) {
const allowedTypes = typeDefinition[prop];
if (!allowedTypes) {
continue;
......@@ -153,8 +162,16 @@ export const isEntityName = field =>
export const isAny = col => true;
export const isNumericBaseType = field =>
field && isa(field.base_type, TYPE.Number);
export const isNumericBaseType = field => {
if (!field) {
return false;
}
if (field.effective_type) {
return isa(field.effective_type, TYPE.Number);
} else {
return isa(field.base_type, TYPE.Number);
}
};
// ZipCode, ID, etc derive from Number but should not be formatted as numbers
export const isNumber = field =>
......@@ -164,7 +181,16 @@ export const isNumber = field =>
export const isBinnedNumber = field => isNumber(field) && !!field.binning_info;
export const isTime = field => field && isa(field.base_type, TYPE.Time);
export const isTime = field => {
if (!field) {
return false;
}
if (field.effective_type) {
return isa(field.effective_type, TYPE.Time);
} else {
return isa(field.base_type, TYPE.Time);
}
};
export const isAddress = field =>
field && isa(field.semantic_type, TYPE.Address);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment