Skip to content
Merged
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
114 changes: 0 additions & 114 deletions lib/assets/connection_cell/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,113 +538,6 @@ export function init(ctx, info) {
`,
};

const AthenaForm = {
name: "AthenaForm",

components: {
BaseInput: BaseInput,
BaseSecret: BaseSecret,
},

props: {
fields: {
type: Object,
default: {},
},
helpBox: {
type: String,
default: "",
},
hasAwsCredentials: {
type: Boolean,
default: false,
},
},

methods: {
areFieldsEmpty(currentField, otherField) {
if (currentField === "" && otherField === "") {
return true;
}

return false;
},
},

template: `
<div class="row mixed-row">
<BaseInput
name="access_key_id"
label="Access Key ID"
type="text"
v-model="fields.access_key_id"
inputClass="input"
:grow
:required="!hasAwsCredentials"
/>
<BaseSecret
textInputName="secret_access_key"
secretInputName="secret_access_key_secret"
toggleInputName="use_secret_access_key_secret"
label="Secret Access Key"
v-model:textInputValue="fields.secret_access_key"
v-model:secretInputValue="fields.secret_access_key_secret"
v-model:toggleInputValue="fields.use_secret_access_key_secret"
modalTitle="Set secret access key"
/>
</div>
<div class="row mixed-row">
<BaseInput
name="token"
label="Session Token"
type="password"
v-model="fields.token"
inputClass="input"
:grow
/>
<BaseInput
name="region"
label="Region"
type="text"
v-model="fields.region"
inputClass="input"
:grow
:required="!hasAwsCredentials"
/>
</div>
<div class="row mixed-row">
<BaseInput
name="database"
label="Database"
type="text"
v-model="fields.database"
inputClass="input"
:grow
:required
/>
<BaseInput
name="workgroup"
label="Workgroup"
type="text"
v-model="fields.workgroup"
inputClass="input"
:grow
:required="!!areFieldsEmpty(fields.workgroup, fields.output_location)"
/>
<BaseInput
name="output_location"
label="Output Location"
type="url"
v-model="fields.output_location"
inputClass="input"
:grow
:required="!!areFieldsEmpty(fields.output_location, fields.workgroup)"
/>
</div>
<small class="help-box" v-if="hasAwsCredentials" v-html="helpBox" />
`,
};

const BigQueryForm = {
name: "BigQueryForm",

Expand Down Expand Up @@ -950,7 +843,6 @@ export function init(ctx, info) {
DefaultSQLForm: DefaultSQLForm,
SQLServerForm: SQLServerForm,
BigQueryForm: BigQueryForm,
AthenaForm: AthenaForm,
ClickhouseForm: ClickhouseForm,
},

Expand Down Expand Up @@ -988,7 +880,6 @@ export function init(ctx, info) {
<SnowflakeForm v-bind:fields="fields" v-if="isSnowflake" />
<ClickhouseForm v-bind:fields="fields" v-if="isClickhouse" />
<BigQueryForm v-bind:fields="fields" v-bind:helpBox="helpBox" v-if="isBigQuery" />
<AthenaForm v-bind:fields="fields" v-bind:helpBox="helpBox" v-bind:hasAwsCredentials="hasAwsCredentials" v-if="isAthena" />
<SQLServerForm v-bind:fields="fields" v-if="isSQLServer" />
<DefaultSQLForm v-bind:fields="fields" v-if="isDefaultDatabase" />
</div>
Expand All @@ -1008,7 +899,6 @@ export function init(ctx, info) {
{ label: "SQLite", value: "sqlite" },
{ label: "DuckDB", value: "duckdb" },
{ label: "Google BigQuery", value: "bigquery" },
{ label: "AWS Athena", value: "athena" },
{ label: "Snowflake", value: "snowflake" },
{ label: "Clickhouse", value: "clickhouse" },
{ label: "SQL Server", value: "sqlserver" },
Expand Down Expand Up @@ -1037,10 +927,6 @@ export function init(ctx, info) {
return this.fields.type === "bigquery";
},

isAthena() {
return this.fields.type === "athena";
},

isSQLServer() {
return this.fields.type === "sqlserver";
},
Expand Down
20 changes: 0 additions & 20 deletions lib/assets/sql_cell/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,6 @@ export function init(ctx, payload) {
inputClass="input input--xs"
:inline
/>
<BaseSwitch
v-if="hasCache"
@change="handleCacheQueryChange"
name="cache_query"
label="Cache"
v-model="payload.cache_query"
:inline
/>
<div class="grow"></div>
<button id="help-toggle" @click="toggleHelpBox" class="icon-button">
<i class="ri ri-questionnaire-line" aria-hidden="true"></i>
Expand All @@ -260,7 +252,6 @@ export function init(ctx, payload) {
mysql: "MySQL",
sqlite: "SQLite",
bigquery: "Google BigQuery",
athena: "AWS Athena",
snowflake: "Snowflake",
sqlserver: "SQL Server",
duckdb: "DuckDB",
Expand Down Expand Up @@ -295,9 +286,6 @@ export function init(ctx, payload) {
]);
}
},
hasCache() {
return this.payload.connection?.type === 'athena';
},
hasTimeout() {
const hasTimeout = ["postgres", "mysql", "sqlite", "sqlserver"];
return hasTimeout.includes(this.payload.connection?.type);
Expand All @@ -321,10 +309,6 @@ export function init(ctx, payload) {
ctx.pushEvent("update_result_variable", value);
},

handleCacheQueryChange({ target: { checked } }) {
ctx.pushEvent("update_cache_query", checked);
},

handleTimeoutChange({ target: { value } }) {
ctx.pushEvent("update_timeout", value);
},
Expand Down Expand Up @@ -354,10 +338,6 @@ export function init(ctx, payload) {
app.payload.connection = connection;
});

ctx.handleEvent("update_cache_query", (value) => {
app.payload.cache_query = value;
});

ctx.handleEvent("update_timeout", (timeout) => {
app.payload.timeout = timeout;
});
Expand Down
1 change: 0 additions & 1 deletion lib/kino_db.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ results = [
MyXQL.Result,
Exqlite.Result,
ReqBigQuery.Result,
ReqAthena.Result,
Tds.Result,
Adbc.Result
]
Expand Down
75 changes: 1 addition & 74 deletions lib/kino_db/connection_cell.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ defmodule KinoDB.ConnectionCell do
"private_key_passphrase_secret" => attrs["private_key_passphrase_secret"] || "",
"token" => attrs["token"] || "",
"region" => attrs["region"] || "us-east-1",
"workgroup" => attrs["workgroup"] || "",
"output_location" => attrs["output_location"] || "",
"account" => attrs["account"] || "",
"schema" => attrs["schema"] || "",
"warehouse" => attrs["warehouse"] || "",
Expand Down Expand Up @@ -144,13 +142,6 @@ defmodule KinoDB.ConnectionCell do
"bigquery" ->
~w|project_id default_dataset_id credentials_json|

"athena" ->
if fields["use_secret_access_key_secret"],
do:
~w|access_key_id secret_access_key_secret token region workgroup output_location database|,
else:
~w|access_key_id secret_access_key token region workgroup output_location database|

"snowflake" ->
snowflake_fields(fields)

Expand Down Expand Up @@ -215,15 +206,6 @@ defmodule KinoDB.ConnectionCell do
"bigquery" ->
~w|project_id|

"athena" ->
if Code.ensure_loaded?(:aws_credentials),
do: ~w|database|,
else:
if(Map.has_key?(attrs, "secret_access_key"),
do: ~w|access_key_id secret_access_key region database|,
else: ~w|access_key_id secret_access_key_secret region database|
)

"snowflake" ->
snowflake_source_required_keys(attrs)

Expand All @@ -237,14 +219,7 @@ defmodule KinoDB.ConnectionCell do
~w|hostname port|
end

conditional_keys =
case attrs["type"] do
"athena" -> ~w|workgroup output_location|
_ -> []
end

if all_fields_filled?(attrs, required_keys) and
any_fields_filled?(attrs, conditional_keys) do
if all_fields_filled?(attrs, required_keys) do
attrs |> to_quoted() |> Kino.SmartCell.quoted_to_string()
else
""
Expand All @@ -269,12 +244,6 @@ defmodule KinoDB.ConnectionCell do
not Enum.any?(keys, fn key -> attrs[key] in [nil, ""] end)
end

defp any_fields_filled?(_, []), do: true

defp any_fields_filled?(attrs, keys) do
Enum.any?(keys, fn key -> attrs[key] not in [nil, ""] end)
end

defp trim_opts(opts) do
Enum.map(opts, fn
{key, value} when is_binary(value) -> {key, String.trim(value)}
Expand Down Expand Up @@ -377,24 +346,6 @@ defmodule KinoDB.ConnectionCell do
end
end

defp to_quoted(%{"type" => "athena"} = attrs) do
quote do
unquote(quoted_var(attrs["variable"])) =
ReqAthena.new(
access_key_id: unquote(attrs["access_key_id"]),
database: unquote(attrs["database"]),
output_location: unquote(attrs["output_location"]),
region: unquote(attrs["region"]),
secret_access_key: unquote(quoted_access_key(attrs)),
token: unquote(attrs["token"]),
workgroup: unquote(attrs["workgroup"]),
http_errors: :raise
)

:ok
end
end

defp to_quoted(%{"type" => "clickhouse"} = attrs) do
trimmed = attrs |> trim_opts() |> Map.new()
shared_opts = shared_options(trimmed)
Expand All @@ -408,16 +359,6 @@ defmodule KinoDB.ConnectionCell do
end
end

defp quoted_access_key(%{"secret_access_key" => password}), do: password

defp quoted_access_key(%{"secret_access_key_secret" => ""}), do: ""

defp quoted_access_key(%{"secret_access_key_secret" => secret}) do
quote do
System.fetch_env!(unquote("LB_#{secret}"))
end
end

defp quoted_private_key(%{"private_key" => pk}), do: pk

defp quoted_private_key(%{"private_key_secret" => ""}), do: ""
Expand Down Expand Up @@ -607,7 +548,6 @@ defmodule KinoDB.ConnectionCell do
Code.ensure_loaded?(Postgrex) -> "postgres"
Code.ensure_loaded?(MyXQL) -> "mysql"
Code.ensure_loaded?(Exqlite) -> "sqlite"
Code.ensure_loaded?(ReqAthena) -> "athena"
Code.ensure_loaded?(ReqCH) -> "clickhouse"
Code.ensure_loaded?(Adbc) -> adbc_default_db_type()
Code.ensure_loaded?(Tds) -> "sqlserver"
Expand Down Expand Up @@ -639,13 +579,6 @@ defmodule KinoDB.ConnectionCell do
end
end

defp missing_dep(%{"type" => "athena"}) do
missing_many_deps([
{ReqAthena, ~s|{:req_athena, "~> 0.3"}|},
{Explorer, ~s|{:explorer, "~> 0.10"}|}
])
end

defp missing_dep(%{"type" => adbc}) when adbc in ~w[duckdb snowflake bigquery] do
unless Code.ensure_loaded?(Adbc) do
~s|{:adbc, "~> 0.3"}|
Expand Down Expand Up @@ -685,12 +618,6 @@ defmodule KinoDB.ConnectionCell do
end
end

defp help_box(%{"type" => "athena"}) do
if Code.ensure_loaded?(:aws_credentials) do
"You must fill in the fields above accordingly or authenticate your machine with AWS CLI authentication."
end
end

defp help_box(_ctx), do: nil

defp running_on_google_metadata? do
Expand Down
9 changes: 0 additions & 9 deletions lib/kino_db/sql_cell.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ defmodule KinoDB.SQLCell do

defp connection_type(connection) when is_struct(connection, Req.Request) do
cond do
Keyword.has_key?(connection.request_steps, :athena_run) -> "athena"
Keyword.has_key?(connection.request_steps, :clickhouse_run) -> "clickhouse"
true -> nil
end
Expand Down Expand Up @@ -227,10 +226,6 @@ defmodule KinoDB.SQLCell do
end

# Req-based
defp to_quoted(%{"connection" => %{"type" => "athena"}} = attrs) do
to_quoted_req_query(attrs, quote(do: ReqAthena), fn _n -> "?" end)
end

defp to_quoted(%{"connection" => %{"type" => "clickhouse"}} = attrs) do
to_quoted_req_query(attrs, quote(do: ReqCH), fn n, inner ->
name =
Expand Down Expand Up @@ -312,10 +307,6 @@ defmodule KinoDB.SQLCell do
when timeout != nil and type in @connection_types_with_timeout,
do: [[timeout: timeout * 1000]]

defp query_opts_args(%{"connection" => %{"type" => "athena"}} = attrs) do
[[format: :explorer] ++ if(attrs["cache_query"], do: [], else: [cache_query: false])]
end

defp query_opts_args(%{"connection" => %{"type" => "clickhouse"}}),
do: [[format: :explorer]]

Expand Down
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ defmodule KinoDB.MixProject do
{:tds, "~> 2.3.4 or ~> 2.4", optional: true},

# Those dependecies are new, so we use stricter versions
{:req_athena, "~> 0.3.0", optional: true},
{:req_ch, "~> 0.1.0", optional: true},

# Dev only
Expand Down
Loading
Loading