Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cubejs-api-gateway/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Query,
NormalizedQueryFilter,
NormalizedQuery,
MemberExpression,
} from './types/query';

import {
Expand Down Expand Up @@ -69,6 +70,7 @@ export {
Query,
NormalizedQueryFilter,
NormalizedQuery,
MemberExpression,
JWTOptions,
CheckAuthFn,
CheckSQLAuthSuccessResponse,
Expand Down
7 changes: 3 additions & 4 deletions packages/cubejs-api-gateway/src/types/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ interface Query {
cache?: CacheMode; // Used in public interface
ungrouped?: boolean;
responseFormat?: ResultType;

// TODO incoming query, query with parsed exprs and query with evaluated exprs are all different types
subqueryJoins?: Array<SubqueryJoins>,

joinHints?: Array<JoinHint>
subqueryJoins?: Array<SubqueryJoins>;
joinHints?: Array<JoinHint>;
requestId?: string;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/cubejs-schema-compiler/src/adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export * from './PostgresQuery';
export * from './MssqlQuery';
export * from './PrestodbQuery';

export { PreAggregationReferences } from '../compiler/CubeEvaluator';

// Candidates to move from this package to drivers packages
// export * from './RedshiftQuery';
// export * from './SnowflakeQuery';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
JoinDefinition,
PreAggregationDefinition,
PreAggregationDefinitionRollup,
type ToString
type ToString,
ViewIncludedMember
} from './CubeSymbols';
import { UserError } from './UserError';
import { BaseQuery, PreAggregationDefinitionExtended } from '../adapter';
Expand Down Expand Up @@ -100,7 +101,7 @@ export type PreAggregationReferences = {
export type PreAggregationInfo = {
id: string,
preAggregationName: string,
preAggregation: unknown,
preAggregation: any,
cube: string,
references: PreAggregationReferences,
refreshKey: unknown,
Expand All @@ -124,6 +125,7 @@ export type EvaluatedFolder = {
};

export type EvaluatedCube = {
name: string;
measures: Record<string, MeasureDefinition>;
dimensions: Record<string, DimensionDefinition>;
segments: Record<string, SegmentDefinition>;
Expand All @@ -136,6 +138,8 @@ export type EvaluatedCube = {
sql?: (...args: any[]) => string;
sqlTable?: (...args: any[]) => string;
accessPolicy?: AccessPolicyDefinition[];
isView?: boolean;
includedMembers?: ViewIncludedMember[];
};

export class CubeEvaluator extends CubeSymbols {
Expand Down
7 changes: 5 additions & 2 deletions packages/cubejs-schema-compiler/src/compiler/CubeSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ export type AccessPolicyDefinition = {
includesMembers?: string[];
excludesMembers?: string[];
};
conditions?: {
if: Function;
}[]
};

export type ViewIncludedMember = {
Expand Down Expand Up @@ -220,7 +223,7 @@ export class CubeSymbols implements TranspilerSymbolResolver {

private builtCubes: Record<string, CubeDefinitionExtended>;

private cubeDefinitions: Record<string, CubeDefinition>;
public cubeDefinitions: Record<string, CubeDefinition>;

private funcArgumentsValues: Record<string, string[]>;

Expand Down Expand Up @@ -912,7 +915,7 @@ export class CubeSymbols implements TranspilerSymbolResolver {
* resolveSymbolsCall are sync. Async support may be added later with deeper
* refactoring.
*/
protected evaluateContextFunction(cube: any, contextFn: any, context: any = {}) {
public evaluateContextFunction(cube: any, contextFn: any, context: any = {}) {
const cubeEvaluator = this;

return cubeEvaluator.resolveSymbolsCall(contextFn, (name: string) => {
Expand Down
20 changes: 15 additions & 5 deletions packages/cubejs-schema-compiler/src/compiler/PrepareCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ export interface CompilerInterface {
compile: (cubes: any[], errorReporter: ErrorReporter) => void;
}

export const prepareCompiler = (repo: SchemaFileRepository, options: PrepareCompilerOptions = {}) => {
export type Compiler = {
compiler: DataSchemaCompiler;
metaTransformer: CubeToMetaTransformer;
cubeEvaluator: CubeEvaluator;
contextEvaluator: ContextEvaluator;
joinGraph: JoinGraph;
compilerCache: CompilerCache;
headCommitId?: string;
compilerId: string;
};

export const prepareCompiler = (repo: SchemaFileRepository, options: PrepareCompilerOptions = {}): Compiler => {
const nativeInstance = options.nativeInstance || new NativeInstance();
const cubeDictionary = new CubeDictionary();
const cubeSymbols = new CubeSymbols();
Expand Down Expand Up @@ -118,9 +129,8 @@ export const prepareCompiler = (repo: SchemaFileRepository, options: PrepareComp
};
};

export const compile = (repo: SchemaFileRepository, options?: PrepareCompilerOptions) => {
export const compile = async (repo: SchemaFileRepository, options?: PrepareCompilerOptions): Promise<Compiler> => {
const compilers = prepareCompiler(repo, options);
return compilers.compiler.compile().then(
() => compilers
);
await compilers.compiler.compile();
return compilers;
};
10 changes: 10 additions & 0 deletions packages/cubejs-schema-compiler/src/compiler/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
export * from './PrepareCompiler';
export * from './UserError';
export * from './converters';
export {
CubeDefinition,
AccessPolicyDefinition,
ViewIncludedMember,
} from './CubeSymbols';
export {
PreAggregationFilters,
PreAggregationInfo,
EvaluatedCube,
} from './CubeEvaluator';
2 changes: 1 addition & 1 deletion packages/cubejs-server-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { CubejsServerCore } = require('./dist/src/core/server');

/**
* After 5 years working with TypeScript, now I know
* that commonjs and nodejs require is not compatibility with using export default
* that commonjs and Node.js require is not compatible with using export default
*/
const toExport = CubejsServerCore;

Expand Down
1 change: 1 addition & 0 deletions packages/cubejs-server-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"codesandbox-import-utils": "^2.1.12",
"cross-spawn": "^7.0.1",
"fs-extra": "^8.1.0",
"graphql": "^15.8.0",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.6",
"is-docker": "^2.1.1",
Expand Down
Loading
Loading