Skip to content

Commit

Permalink
feat: add pre run scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Jul 31, 2024
1 parent 02926e0 commit bdc9d5c
Show file tree
Hide file tree
Showing 28 changed files with 4,378 additions and 4,009 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export interface ConnectionConfig {
| { $case: "clickhouse"; clickhouse: ConnectionConfig_ConnectionConfigClickHouse }
| undefined;
vars: Var[];
/**
* pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for
* setting up the database for the run job. For example creating UDFs or installing plugins ...
* The scripts are run in order and should be idempotent.
* The list points to the location of the script in the project.
*/
preRunScripts: string[];
}

export interface ConnectionConfig_ConnectionConfigSqLite {
Expand Down Expand Up @@ -149,7 +156,7 @@ export const Var = {
};

function createBaseConnectionConfig(): ConnectionConfig {
return { config: undefined, vars: [] };
return { config: undefined, vars: [], preRunScripts: [] };
}

export const ConnectionConfig = {
Expand Down Expand Up @@ -189,6 +196,9 @@ export const ConnectionConfig = {
for (const v of message.vars) {
Var.encode(v!, writer.uint32(66).fork()).ldelim();
}
for (const v of message.preRunScripts) {
writer.uint32(90).string(v!);
}
return writer;
},

Expand Down Expand Up @@ -296,6 +306,13 @@ export const ConnectionConfig = {

message.vars.push(Var.decode(reader, reader.uint32()));
continue;
case 11:
if (tag !== 90) {
break;
}

message.preRunScripts.push(reader.string());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
Expand Down Expand Up @@ -333,6 +350,7 @@ export const ConnectionConfig = {
? { $case: "clickhouse", clickhouse: ConnectionConfig_ConnectionConfigClickHouse.fromJSON(object.clickhouse) }
: undefined,
vars: gt.Array.isArray(object?.vars) ? object.vars.map((e: any) => Var.fromJSON(e)) : [],
preRunScripts: gt.Array.isArray(object?.preRunScripts) ? object.preRunScripts.map((e: any) => gt.String(e)) : [],
};
},

Expand Down Expand Up @@ -368,6 +386,9 @@ export const ConnectionConfig = {
if (message.vars?.length) {
obj.vars = message.vars.map((e) => Var.toJSON(e));
}
if (message.preRunScripts?.length) {
obj.preRunScripts = message.preRunScripts;
}
return obj;
},

Expand Down Expand Up @@ -453,6 +474,7 @@ export const ConnectionConfig = {
};
}
message.vars = object.vars?.map((e) => Var.fromPartial(e)) || [];
message.preRunScripts = object.preRunScripts?.map((e) => e) || [];
return message;
},
};
Expand Down
4 changes: 4 additions & 0 deletions js/packages/quary-extension-ui/src/views/OnboardingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ const DatabaseSelection: React.FC<{
sqliteInMemory: {},
},
vars: [],
preRunScripts: [],
})
break
}
Expand Down Expand Up @@ -329,6 +330,7 @@ const ConfigurationDetails: React.FC<ConfigurationDetailsProps> = ({
},
},
vars: [],
preRunScripts: [],
}
case DatabaseOnboardingOptions.SQLite:
return {
Expand All @@ -339,6 +341,7 @@ const ConfigurationDetails: React.FC<ConfigurationDetailsProps> = ({
},
},
vars: [],
preRunScripts: [],
}
case DatabaseOnboardingOptions.Snowflake:
return {
Expand All @@ -351,6 +354,7 @@ const ConfigurationDetails: React.FC<ConfigurationDetailsProps> = ({
},
},
vars: [],
preRunScripts: [],
}
default: {
throw new Error(`invalid database type ${states.sourceDetails.type}`)
Expand Down
11 changes: 11 additions & 0 deletions proto/gen/es/quary/service/v1/connection_config_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ export class ConnectionConfig extends Message<ConnectionConfig> {
*/
vars: Var[] = [];

/**
* pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for
* setting up the database for the run job. For example creating UDFs or installing plugins ...
* The scripts are run in order and should be idempotent.
* The list points to the location of the script in the project.
*
* @generated from field: repeated string pre_run_scripts = 11;
*/
preRunScripts: string[] = [];

constructor(data?: PartialMessage<ConnectionConfig>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -137,6 +147,7 @@ export class ConnectionConfig extends Message<ConnectionConfig> {
{ no: 9, name: "redshift", kind: "message", T: ConnectionConfig_ConnectionConfigRedshift, oneof: "config" },
{ no: 10, name: "clickhouse", kind: "message", T: ConnectionConfig_ConnectionConfigClickHouse, oneof: "config" },
{ no: 8, name: "vars", kind: "message", T: Var, repeated: true },
{ no: 11, name: "pre_run_scripts", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ConnectionConfig {
Expand Down
7 changes: 7 additions & 0 deletions proto/gen/json_schema/ConnectionConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
},
"additionalProperties": false,
"type": "array"
},
"pre_run_scripts": {
"items": {
"type": "string"
},
"type": "array",
"description": "pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for setting up the database for the run job. For example creating UDFs or installing plugins ... The scripts are run in order and should be idempotent. The list points to the location of the script in the project."
}
},
"additionalProperties": false,
Expand Down
7 changes: 7 additions & 0 deletions proto/gen/json_schema/GenerateProjectFilesRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
},
"additionalProperties": false,
"type": "array"
},
"pre_run_scripts": {
"items": {
"type": "string"
},
"type": "array",
"description": "pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for setting up the database for the run job. For example creating UDFs or installing plugins ... The scripts are run in order and should be idempotent. The list points to the location of the script in the project."
}
},
"additionalProperties": false,
Expand Down
7 changes: 7 additions & 0 deletions proto/gen/json_schema/GetProjectConfigResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
},
"additionalProperties": false,
"type": "array"
},
"pre_run_scripts": {
"items": {
"type": "string"
},
"type": "array",
"description": "pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for setting up the database for the run job. For example creating UDFs or installing plugins ... The scripts are run in order and should be idempotent. The list points to the location of the script in the project."
}
},
"additionalProperties": false,
Expand Down
7 changes: 7 additions & 0 deletions proto/gen/json_schema/ParseProjectResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@
},
"additionalProperties": false,
"type": "array"
},
"pre_run_scripts": {
"items": {
"type": "string"
},
"type": "array",
"description": "pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for setting up the database for the run job. For example creating UDFs or installing plugins ... The scripts are run in order and should be idempotent. The list points to the location of the script in the project."
}
},
"additionalProperties": false,
Expand Down
7 changes: 7 additions & 0 deletions proto/gen/json_schema/Project.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@
},
"additionalProperties": false,
"type": "array"
},
"pre_run_scripts": {
"items": {
"type": "string"
},
"type": "array",
"description": "pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for setting up the database for the run job. For example creating UDFs or installing plugins ... The scripts are run in order and should be idempotent. The list points to the location of the script in the project."
}
},
"additionalProperties": false,
Expand Down
7 changes: 7 additions & 0 deletions proto/gen/json_schema/ReturnSQLForSeedsAndModelsResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@
},
"additionalProperties": false,
"type": "array"
},
"pre_run_scripts": {
"items": {
"type": "string"
},
"type": "array",
"description": "pre_run_scripts is a list of scripts that should be run before a run job against the database. This is useful for setting up the database for the run job. For example creating UDFs or installing plugins ... The scripts are run in order and should be idempotent. The list points to the location of the script in the project."
}
},
"additionalProperties": false,
Expand Down
Loading

0 comments on commit bdc9d5c

Please sign in to comment.