Revert "Feature: Snowflake integration (#996)" (#1046)

This reverts commit d4c4501d63.
This commit is contained in:
Akshay 2021-10-14 22:10:18 +05:30 committed by GitHub
parent b23746084b
commit ceca48b100
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 61 additions and 2062 deletions

View file

@ -1 +1 @@
node_modules/**
node_modules/**

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 60 KiB

View file

@ -22,15 +22,6 @@ export const defaultOptions = {
username: { value: '' },
password: { value: '' },
},
snowflake: {
username: { value: '' },
account: { value: '' },
database: { value: '' },
warehouse: { value: '' },
schema: { value: '' },
role: { value: '' },
password: { value: '' },
},
redis: {
host: { value: 'localhost' },
port: { value: 6379 },

View file

@ -1,70 +0,0 @@
{
"$schema": "https://json-schema.org/",
"$id": "https://tooljet.io/Snowflake.schema.json",
"title": "Snowflake datasource",
"description": "A schema defining snowflake datasource",
"type": "object",
"source": {
"name": "Snowflake",
"kind": "snowflake",
"exposedVariables": {
"isLoading": {},
"data": {},
"rawData": {}
},
"options": {
"username": { "type": "string" },
"account": { "type": "string" },
"database": { "type": "string" },
"warehouse": { "type": "string" },
"schema": { "type": "string" },
"role": { "type": "string" },
"password": { "type": "string", "encrypted": true }
}
},
"properties": {
"username": {
"$label": "Username",
"$key": "username",
"type": "text",
"description": "Enter username"
},
"account": {
"$label": "Account",
"$key": "account",
"type": "text",
"description": "Enter account"
},
"database": {
"$label": "Database Name",
"$key": "database",
"type": "text",
"description": "Name of the database"
},
"warehouse": {
"$label": "Warehouse",
"$key": "warehouse",
"type": "text",
"description": "Enter warehouse"
},
"schema": {
"$label": "Schema",
"$key": "schema",
"type": "text",
"description": "Enter schema"
},
"role": {
"$label": "Role",
"$key": "role",
"type": "text",
"description": "Enter role"
},
"password": {
"$label": "Password",
"$key": "password",
"type": "password",
"description": "Enter password"
}
},
"required": ["account", "username"]
}

View file

@ -1,37 +1,53 @@
import React from 'react';
import React from "react";
import DynamicForm from '@/_components/DynamicForm';
import DynamicForm from "@/_components/DynamicForm";
import AirtableSchema from './Api/Airtable.schema.json';
import RestapiSchema from './Api/Restapi.schema.json';
import GraphqlSchema from './Api/Graphql.schema.json';
import StripeSchema from './Api/Stripe.schema.json';
import GooglesheetSchema from './Api/Googlesheets.schema.json';
import SlackSchema from './Api/Slack.schema.json';
import AirtableSchema from "./Api/Airtable.schema.json";
import RestapiSchema from "./Api/Restapi.schema.json";
import GraphqlSchema from "./Api/Graphql.schema.json";
import StripeSchema from "./Api/Stripe.schema.json";
import GooglesheetSchema from "./Api/Googlesheets.schema.json";
import SlackSchema from "./Api/Slack.schema.json";
import DynamodbSchema from './Database/Dynamodb.schema.json';
import ElasticsearchSchema from './Database/Elasticsearch.schema.json';
import RedisSchema from './Database/Redis.schema.json';
import FirestoreSchema from './Database/Firestore.schema.json';
import MongodbSchema from './Database/Mongodb.schema.json';
import PostgresqlSchema from './Database/Postgresql.schema.json';
import MysqlSchema from './Database/Mysql.schema.json';
import MssqlSchema from './Database/Mssql.schema.json';
import SnowflakeSchema from './Database/Snowflake.schema.json';
import DynamodbSchema from "./Database/Dynamodb.schema.json";
import ElasticsearchSchema from "./Database/Elasticsearch.schema.json";
import RedisSchema from "./Database/Redis.schema.json";
import FirestoreSchema from "./Database/Firestore.schema.json";
import MongodbSchema from "./Database/Mongodb.schema.json";
import PostgresqlSchema from "./Database/Postgresql.schema.json";
import MysqlSchema from "./Database/Mysql.schema.json";
import MssqlSchema from "./Database/Mssql.schema.json";
const Airtable = ({ ...rest }) => <DynamicForm schema={AirtableSchema} {...rest} />;
const Restapi = ({ ...rest }) => <DynamicForm schema={RestapiSchema} {...rest} />;
const Graphql = ({ ...rest }) => <DynamicForm schema={GraphqlSchema} {...rest} />;
const Airtable = ({ ...rest }) => (
<DynamicForm schema={AirtableSchema} {...rest} />
);
const Restapi = ({ ...rest }) => (
<DynamicForm schema={RestapiSchema} {...rest} />
);
const Graphql = ({ ...rest }) => (
<DynamicForm schema={GraphqlSchema} {...rest} />
);
const Stripe = ({ ...rest }) => <DynamicForm schema={StripeSchema} {...rest} />;
const Googlesheets = ({ ...rest }) => <DynamicForm schema={GooglesheetSchema} {...rest} />;
const Googlesheets = ({ ...rest }) => (
<DynamicForm schema={GooglesheetSchema} {...rest} />
);
const Slack = ({ ...rest }) => <DynamicForm schema={SlackSchema} {...rest} />;
const Dynamodb = ({ ...rest }) => <DynamicForm schema={DynamodbSchema} {...rest} />;
const Elasticsearch = ({ ...rest }) => <DynamicForm schema={ElasticsearchSchema} {...rest} />;
const Dynamodb = ({ ...rest }) => (
<DynamicForm schema={DynamodbSchema} {...rest} />
);
const Elasticsearch = ({ ...rest }) => (
<DynamicForm schema={ElasticsearchSchema} {...rest} />
);
const Redis = ({ ...rest }) => <DynamicForm schema={RedisSchema} {...rest} />;
const Firestore = ({ ...rest }) => <DynamicForm schema={FirestoreSchema} {...rest} />;
const Mongodb = ({ ...rest }) => <DynamicForm schema={MongodbSchema} {...rest} />;
const Postgresql = ({ ...rest }) => <DynamicForm schema={PostgresqlSchema} {...rest} />;
const Snowflake = ({ ...rest }) => <DynamicForm schema={SnowflakeSchema} {...rest} />;
const Firestore = ({ ...rest }) => (
<DynamicForm schema={FirestoreSchema} {...rest} />
);
const Mongodb = ({ ...rest }) => (
<DynamicForm schema={MongodbSchema} {...rest} />
);
const Postgresql = ({ ...rest }) => (
<DynamicForm schema={PostgresqlSchema} {...rest} />
);
const Mysql = ({ ...rest }) => <DynamicForm schema={MysqlSchema} {...rest} />;
const Mssql = ({ ...rest }) => <DynamicForm schema={MssqlSchema} {...rest} />;
@ -44,7 +60,6 @@ export const DataBaseSources = [
PostgresqlSchema.source,
MysqlSchema.source,
MssqlSchema.source,
SnowflakeSchema.source,
];
export const ApiSources = [
AirtableSchema.source,
@ -71,5 +86,4 @@ export const SourceComponents = {
Graphql,
Mysql,
Mssql,
Snowflake,
};

View file

@ -1,41 +0,0 @@
import React from 'react';
import { CodeHinter } from '../../CodeBuilder/CodeHinter';
import { changeOption } from './utils';
class Snowflake extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
this.setState({
options: this.props.options,
});
}
render() {
const { options } = this.state;
return (
<div>
{options && (
<div className="mb-3 mt-2">
<CodeHinter
currentState={this.props.currentState}
initialValue={options.query}
mode="sql"
theme={this.props.darkMode ? 'monokai' : 'duotone-light'}
lineNumbers={true}
className="query-hinter"
onChange={(value) => changeOption(this, 'query', value)}
/>
</div>
)}
</div>
);
}
}
export { Snowflake };

View file

@ -12,7 +12,6 @@ import { Dynamodb } from './Dynamodb';
import { Airtable } from './Airtable';
import { Graphql } from './Graphql';
import { Mssql } from './Mssql';
import { Snowflake } from './Snowflake';
export const allSources = {
Restapi,
@ -29,5 +28,4 @@ export const allSources = {
Airtable,
Graphql,
Mssql,
Snowflake,
};

View file

@ -34,5 +34,4 @@ export const defaultOptions = {
dynamodb: {},
airtable: {},
mssql: {},
snowflake: {},
};

1798
server/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -43,7 +43,6 @@
"@types/got": "^9.6.12",
"@types/humps": "^2.0.1",
"@types/nodemailer": "^6.4.4",
"@types/snowflake-sdk": "^1.6.1",
"aws-sdk": "^2.947.0",
"bcrypt": "^5.0.1",
"dotenv": "^10.0.0",
@ -66,7 +65,6 @@
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"semver": "^7.3.5",
"snowflake-sdk": "^1.6.3",
"tedious": "^11.2.0",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.10.1",

View file

@ -1,100 +0,0 @@
import { Injectable } from '@nestjs/common';
import { QueryResult } from 'src/modules/data_sources/query_result.type';
import { ConnectionTestResult } from 'src/modules/data_sources/connection_test_result.type';
import { QueryService } from 'src/modules/data_sources/query_service.interface';
import { QueryError } from 'src/modules/data_sources/query.error';
import { cacheConnection, getCachedConnection } from 'src/helpers/utils.helper';
import * as snowflake from 'snowflake-sdk';
// Snowflake does not support promise based api and therefore we need to wrap
// connection callbacks within a promise to handle accordingly
// https://github.com/snowflakedb/snowflake-connector-nodejs/issues/3
import { promisify } from 'util';
@Injectable()
export default class snowflakeQueryService implements QueryService {
async connExecuteAsync(connection: snowflake.Connection, options: any) {
return new Promise((resolve, reject) => {
connection.execute({
...options,
complete: function (err, stmt, rows) {
if (err) {
reject(err);
} else {
resolve({ stmt, rows });
}
},
});
});
}
async run(
sourceOptions: any,
queryOptions: any,
dataSourceId: string,
dataSourceUpdatedAt: string
): Promise<QueryResult> {
const sqlText = queryOptions.query;
const connection: snowflake.Connection = await this.getConnection(
sourceOptions,
{},
true,
dataSourceId,
dataSourceUpdatedAt
);
try {
const result: any = await this.connExecuteAsync(connection, {
sqlText,
});
return { status: 'ok', data: result.rows };
} catch (err) {
throw new QueryError('Query could not be completed', err.message, {});
}
}
async testConnection(sourceOptions: object): Promise<ConnectionTestResult> {
await this.getConnection(sourceOptions, {}, false);
return { status: 'ok' };
}
async buildConnection(sourceOptions: any) {
const connection = snowflake.createConnection({
account: sourceOptions.account,
username: sourceOptions.username,
password: sourceOptions.password,
database: sourceOptions.database,
warehouse: sourceOptions.warehouse,
schema: sourceOptions.schema,
role: sourceOptions.role,
});
const connectAsync = promisify(connection.connect);
await connectAsync();
return connection;
}
async getConnection(
sourceOptions: any,
options: any,
checkCache: boolean,
dataSourceId?: string,
dataSourceUpdatedAt?: string
): Promise<any> {
if (checkCache) {
let connection = await getCachedConnection(dataSourceId, dataSourceUpdatedAt);
if (connection) {
return connection;
} else {
connection = await this.buildConnection(sourceOptions);
await cacheConnection(dataSourceId, connection);
return connection;
}
} else {
return await this.buildConnection(sourceOptions);
}
}
}