diff --git a/packages/cubejs-client-core/index.d.ts b/packages/cubejs-client-core/index.d.ts index 9483a96696df..ce2b4c6e8ee4 100644 --- a/packages/cubejs-client-core/index.d.ts +++ b/packages/cubejs-client-core/index.d.ts @@ -80,6 +80,7 @@ declare module '@cubejs-client/core' { credentials?: 'omit' | 'same-origin' | 'include'; parseDateMeasures?: boolean; resType?: 'default' | 'compact'; + castNumerics?: boolean; }; export type LoadMethodOptions = { diff --git a/packages/cubejs-client-core/src/index.js b/packages/cubejs-client-core/src/index.js index d4c8ef6f5bb2..fac5642c3d4a 100644 --- a/packages/cubejs-client-core/src/index.js +++ b/packages/cubejs-client-core/src/index.js @@ -56,6 +56,7 @@ class CubeApi { }); this.pollInterval = options.pollInterval || 5; this.parseDateMeasures = options.parseDateMeasures; + this.castNumerics = typeof options.castNumerics === 'boolean' ? options.castNumerics : false; this.updateAuthorizationPromise = null; } @@ -308,6 +309,11 @@ class CubeApi { } load(query, options, callback, responseFormat = ResultType.DEFAULT) { + options = { + castNumerics: this.castNumerics, + ...options + }; + if (responseFormat === ResultType.COMPACT) { if (Array.isArray(query)) { query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT)); @@ -327,6 +333,11 @@ class CubeApi { } subscribe(query, options, callback, responseFormat = ResultType.DEFAULT) { + options = { + castNumerics: this.castNumerics, + ...options + }; + if (responseFormat === ResultType.COMPACT) { if (Array.isArray(query)) { query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT));