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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "snowflake-insert-multiple-rows",
name: "Insert Multiple Rows",
description: "Insert multiple rows into a table",
version: "0.1.5",
version: "0.2.0",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -15,39 +15,24 @@ export default {
props: {
snowflake,
database: {
propDefinition: [
snowflake,
"database",
],
type: "string",
label: "Database",
description: "The database to use. Run **List Database Options** to find available databases.",
},
schema: {
propDefinition: [
snowflake,
"schema",
(c) => ({
database: c.database,
}),
],
type: "string",
label: "Schema",
description: "The schema to use. Run **List Schema Options** to find available schemas.",
},
tableName: {
propDefinition: [
snowflake,
"tableName",
(c) => ({
database: c.database,
schema: c.schema,
}),
],
description: "The table where you want to add rows",
type: "string",
label: "Table Name",
description: "The table where you want to add rows. Run **List Table Options** to find available tables.",
},
columns: {
propDefinition: [
snowflake,
"columns",
(c) => ({
tableName: c.tableName,
}),
],
type: "string[]",
label: "Columns",
description: "The columns you want to insert data into. Run **List Column Options** to find available columns.",
},
values: {
propDefinition: [
Expand Down Expand Up @@ -82,6 +67,7 @@ export default {
},
},
async run({ $ }) {
const tableName = `${this.database}.${this.schema}.${this.tableName}`;
let rows = this.values;

let inputValidated = true;
Expand Down Expand Up @@ -132,7 +118,7 @@ export default {

try {
const response = await this.snowflake.insertRows(
this.tableName,
tableName,
this.columns,
rows,
batchOptions,
Expand All @@ -142,7 +128,7 @@ export default {
if (response.summary) {
// Batched response
const { summary } = response;
$.export("$summary", `Successfully inserted ${summary.totalRowsProcessed} rows into ${this.tableName} using ${summary.totalBatches} batches`);
$.export("$summary", `Successfully inserted ${summary.totalRowsProcessed} rows into ${tableName} using ${summary.totalBatches} batches`);

// Export detailed batch information
$.export("batchDetails", {
Expand All @@ -161,7 +147,7 @@ export default {

} else {
// Single insert response (small dataset or batching disabled)
$.export("$summary", `Successfully inserted ${rows.length} rows into ${this.tableName}`);
$.export("$summary", `Successfully inserted ${rows.length} rows into ${tableName}`);
return response;
}

Expand Down
43 changes: 17 additions & 26 deletions components/snowflake/actions/insert-row/insert-row.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "snowflake-insert-row",
name: "Insert Single Row",
description: "Insert a row into a table",
version: "1.1.5",
version: "1.2.0",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -14,38 +14,28 @@ export default {
props: {
snowflake,
database: {
propDefinition: [
snowflake,
"database",
],
type: "string",
label: "Database",
description: "The database to use. Run **List Database Options** to find available databases.",
},
schema: {
propDefinition: [
snowflake,
"schema",
(c) => ({
database: c.database,
}),
],
type: "string",
label: "Schema",
description: "The schema to use. Run **List Schema Options** to find available schemas.",
},
tableName: {
propDefinition: [
snowflake,
"tableName",
(c) => ({
database: c.database,
schema: c.schema,
}),
],
description: "The table where you want to add a new row",
type: "string",
label: "Table Name",
description: "The table where you want to add a new row. Run **List Table Options** to find available tables.",
reloadProps: true,
},
},
async additionalProps() {
const props = {};
// Once a user selects the table, display the columns as additional props
if (this.tableName) {
const fields = await this.snowflake.listFieldsForTable(this.tableName);
// Once a user provides the table, display the columns as additional props
if (this.database && this.schema && this.tableName) {
const tableName = `${this.database}.${this.schema}.${this.tableName}`;
const fields = await this.snowflake.listFieldsForTable(tableName);
const defaultValue = {};
for (const field of fields) {
defaultValue[field.name] = "";
Expand All @@ -60,8 +50,9 @@ export default {
return props;
},
async run({ $ }) {
const response = await this.snowflake.insertRow(this.tableName, this.values);
$.export("$summary", `Successfully inserted row in ${this.tableName}`);
const tableName = `${this.database}.${this.schema}.${this.tableName}`;
const response = await this.snowflake.insertRow(tableName, this.values);
$.export("$summary", `Successfully inserted row in ${tableName}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import snowflake from "../../snowflake.app.mjs";

export default {
key: "snowflake-list-column-options",
name: "List Column Options",
description: "Retrieves available options for the Columns field.",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
snowflake,
database: {
type: "string",
label: "Database",
description: "The database the table belongs to. Run **List Database Options** to find available databases.",
},
schema: {
type: "string",
label: "Schema",
description: "The schema the table belongs to. Run **List Schema Options** to find available schemas.",
},
tableName: {
type: "string",
label: "Table Name",
description: "The table to list columns for. Run **List Table Options** to find available tables.",
},
},
async run({ $ }) {
const tableName = `${this.database}.${this.schema}.${this.tableName}`;
const options = await this.snowflake.listFieldsForTable(tableName);
const names = options.map((i) => i.name);
$.export("$summary", `Successfully retrieved ${names.length} option${names.length === 1
? ""
: "s"}`);
return names;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import snowflake from "../../snowflake.app.mjs";

export default {
key: "snowflake-list-schema-options",
name: "List Schema Options",
description: "Retrieves available options for the Schema field.",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
snowflake,
database: {
type: "string",
label: "Database",
description: "The database to list schemas for. Run **List Database Options** to find available databases.",
},
},
async run({ $ }) {
const options = await this.snowflake.listSchemas(this.database);
const names = options.map((i) => i.name);
$.export("$summary", `Successfully retrieved ${names.length} option${names.length === 1
? ""
: "s"}`);
return names;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import snowflake from "../../snowflake.app.mjs";

export default {
key: "snowflake-list-table-options",
name: "List Table Options",
description: "Retrieves available options for the Table Name field.",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
snowflake,
database: {
type: "string",
label: "Database",
description: "The database to list tables for. Run **List Database Options** to find available databases.",
},
schema: {
type: "string",
label: "Schema",
description: "The schema to list tables for. Run **List Schema Options** to find available schemas.",
},
},
async run({ $ }) {
const options = await this.snowflake.listTables({
database: this.database,
schema: this.schema,
});
const names = options.map((i) => i.name);
$.export("$summary", `Successfully retrieved ${names.length} option${names.length === 1
? ""
: "s"}`);
return names;
},
};
2 changes: 1 addition & 1 deletion components/snowflake/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/snowflake",
"version": "0.14.0",
"version": "0.15.0",
"description": "Pipedream Snowflake Components",
"main": "snowflake.app.mjs",
"keywords": [
Expand Down
Loading
Loading