Skip to content

Commit

Permalink
[BENCH-5181] Fix range data conversion in requests (#1169)
Browse files Browse the repository at this point in the history
* Squash and merge

* Squash and merge
  • Loading branch information
dexamundsen authored Feb 13, 2025
1 parent cb095fc commit 0df888a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ public static Literal fromApiObject(ApiLiteral apiLiteral) {
apiLiteral.getValueUnion().getInt64Val() != null
? Long.parseLong(apiLiteral.getValueUnion().getInt64Val())
: null);
case DOUBLE -> Literal.forDouble(apiLiteral.getValueUnion().getDoubleVal());
case STRING -> Literal.forString(apiLiteral.getValueUnion().getStringVal());
case BOOLEAN -> Literal.forBoolean(apiLiteral.getValueUnion().isBoolVal());
case DATE -> Literal.forDate(apiLiteral.getValueUnion().getDateVal());
Expand Down
20 changes: 13 additions & 7 deletions ui/src/data/source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as tanagra from "tanagra-api";
import * as tanagraUnderlay from "tanagra-underlay/underlayConfig";
import { Underlay } from "underlaysSlice";
import { isValid } from "util/valid";
import { DataType } from "tanagra-api";

export type EntityNode = {
data: DataEntry;
Expand Down Expand Up @@ -1036,7 +1037,7 @@ export class BackendUnderlaySource implements UnderlaySource {
}

const limit = options?.fetchAll ? 100000 : options?.limit;
const req = {
return {
entityName: entity.name,
underlayName: this.underlay.name,
query: {
Expand Down Expand Up @@ -1074,7 +1075,6 @@ export class BackendUnderlaySource implements UnderlaySource {
pageMarker: options?.pageMarker,
},
};
return req;
}

private async queryHints(
Expand Down Expand Up @@ -1606,19 +1606,26 @@ function isInternalAttribute(attribute: string): boolean {
}

export function literalFromDataValue(value: DataValue): tanagra.Literal {
let dataType = tanagra.DataType.Int64;
if (typeof value === "string") {
let dataType: DataType;
if (typeof value === "bigint") {
dataType = tanagra.DataType.Int64;
} else if (typeof value == "number") {
dataType = tanagra.DataType.Double;
} else if (typeof value === "string") {
dataType = tanagra.DataType.String;
} else if (typeof value === "boolean") {
dataType = tanagra.DataType.Boolean;
} else if (value instanceof Date) {
dataType = tanagra.DataType.Date;
} else {
throw new Error(`Unsupported type of ${JSON.stringify(value)}.`);
}

return {
dataType,
valueUnion: {
int64Val: typeof value === "bigint" ? String(value) : undefined,
doubleVal: typeof value === "number" ? value : undefined,
stringVal: typeof value === "string" ? value : undefined,
boolVal: typeof value === "boolean" ? value : undefined,
dateVal: value instanceof Date ? value.toISOString() : undefined,
Expand Down Expand Up @@ -2106,7 +2113,7 @@ function fromAPIFeatureSetInternal(
function toAPICriteriaGroupSections(
groupSections: GroupSection[]
): tanagra.CriteriaGroupSection[] {
const sections = groupSections.map((section) => ({
return groupSections.map((section) => ({
id: section.id,
displayName: section.name ?? "",
operator: toAPICriteriaGroupSectionOperator(section.filter.kind),
Expand All @@ -2122,7 +2129,6 @@ function toAPICriteriaGroupSections(
),
disabled: !!section.disabled,
}));
return sections;
}

function toAPICriteriaGroups(groups: Group[]): tanagra.CriteriaGroup[] {
Expand Down Expand Up @@ -2252,7 +2258,7 @@ function parseAPIError<T>(p: Promise<T>) {
}

const text = await response.text();
let message = "";
let message;
try {
message = JSON.parse(text).message;
} catch (e) {
Expand Down

0 comments on commit 0df888a

Please sign in to comment.