Skip to content

Commit

Permalink
feat(CE): add table selector as model query type (#234) (#213)
Browse files Browse the repository at this point in the history
Co-authored-by: datafloyd <[email protected]>
  • Loading branch information
github-actions[bot] and subintp authored Jul 1, 2024
1 parent 9ad2caa commit 71b24b2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion server/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gem "interactor", "~> 3.0"

gem "ruby-odbc", git: "https://github.com/Multiwoven/ruby-odbc.git"

gem "multiwoven-integrations", "~> 0.3.0"
gem "multiwoven-integrations", "~> 0.3.1"

gem "temporal-ruby", github: "coinbase/temporal-ruby"

Expand Down
36 changes: 18 additions & 18 deletions server/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ GEM
appsignal (3.7.5)
rack
ast (2.4.2)
async (2.12.0)
async (2.12.1)
console (~> 1.25, >= 1.25.2)
fiber-annotation
io-event (~> 1.6)
async-http (0.67.1)
io-event (~> 1.6, >= 1.6.5)
async-http (0.69.0)
async (>= 2.10.2)
async-pool (>= 0.6.1)
io-endpoint (~> 0.10, >= 0.10.3)
async-pool (~> 0.7)
io-endpoint (~> 0.11)
io-stream (~> 0.4)
protocol-http (~> 0.26.0)
protocol-http1 (~> 0.19.0)
protocol-http2 (~> 0.18.0)
traces (>= 0.10.0)
async-pool (0.6.1)
protocol-http (~> 0.26)
protocol-http1 (~> 0.19)
protocol-http2 (~> 0.18)
traces (>= 0.10)
async-pool (0.7.0)
async (>= 1.25)
async-websocket (0.26.2)
async-http (~> 0.54)
Expand Down Expand Up @@ -1730,7 +1730,7 @@ GEM
dry-initializer (~> 3.0)
dry-schema (>= 1.12, < 2)
zeitwerk (~> 2.6)
duckdb (1.0.0.1)
duckdb (1.0.0.2)
bigdecimal (>= 3.1.4)
ecma-re-validator (0.4.0)
regexp_parser (~> 2.2)
Expand Down Expand Up @@ -1842,8 +1842,8 @@ GEM
inflection (1.0.0)
interactor (3.1.2)
io-console (0.7.1)
io-endpoint (0.10.3)
io-event (1.6.4)
io-endpoint (0.11.0)
io-event (1.6.5)
io-stream (0.4.0)
irb (1.11.1)
rdoc
Expand Down Expand Up @@ -1892,7 +1892,7 @@ GEM
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.4.1)
multiwoven-integrations (0.3.0)
multiwoven-integrations (0.3.1)
activesupport
async-websocket
aws-sdk-athena
Expand Down Expand Up @@ -1965,7 +1965,7 @@ GEM
premailer (~> 1.7, >= 1.7.9)
process_executer (1.1.0)
protocol-hpack (1.4.3)
protocol-http (0.26.5)
protocol-http (0.26.6)
protocol-http1 (0.19.1)
protocol-http (~> 0.22)
protocol-http2 (0.18.0)
Expand Down Expand Up @@ -2114,9 +2114,9 @@ GEM
faraday-multipart
gli
hashie
sorbet-runtime (0.5.11439)
sorbet-runtime (0.5.11447)
stringio (3.1.0)
stripe (11.7.0)
stripe (12.0.0)
strong_migrations (1.8.0)
activerecord (>= 5.2)
thor (1.3.0)
Expand Down Expand Up @@ -2188,7 +2188,7 @@ DEPENDENCIES
jwt
kaminari
liquid
multiwoven-integrations (~> 0.3.0)
multiwoven-integrations (~> 0.3.1)
mysql2
newrelic_rpm
parallel
Expand Down
2 changes: 1 addition & 1 deletion server/app/models/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Model < ApplicationRecord
validates :name, presence: true
validates :query, presence: true
validates :primary_key, presence: true
enum :query_type, %i[raw_sql dbt soql]
enum :query_type, %i[raw_sql dbt soql table_selector]

belongs_to :workspace
belongs_to :connector
Expand Down
2 changes: 1 addition & 1 deletion server/spec/models/model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

describe "query_type" do
it "defines query_type enum with specified values" do
expect(Model.query_types).to eq({ "raw_sql" => 0, "dbt" => 1, "soql" => 2 })
expect(Model.query_types).to eq({ "raw_sql" => 0, "dbt" => 1, "soql" => 2, "table_selector" => 3 })
end
end
end
15 changes: 15 additions & 0 deletions server/spec/requests/api/v1/models_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@
expect(response_hash.dig(:data, :attributes, :primary_key)).to eq(request_body.dig(:model, :primary_key))
end

it "creates a new model with query type table selector" do
request = request_body
request[:model][:query_type] = "table_selector"
post "/api/v1/models", params: request.to_json, headers: { "Content-Type": "application/json" }
.merge(auth_headers(user, workspace_id))

expect(response).to have_http_status(:created)
response_hash = JSON.parse(response.body).with_indifferent_access
expect(response_hash.dig(:data, :id)).to be_present
expect(response_hash.dig(:data, :attributes, :name)).to eq(request_body.dig(:model, :name))
expect(response_hash.dig(:data, :attributes, :query)).to eq(request_body.dig(:model, :query))
expect(response_hash.dig(:data, :attributes, :query_type)).to eq("table_selector")
expect(response_hash.dig(:data, :attributes, :primary_key)).to eq(request_body.dig(:model, :primary_key))
end

it "returns fail viwer role" do
workspace.workspace_users.first.update(role: viewer_role)
post "/api/v1/models", params: request_body.to_json, headers: { "Content-Type": "application/json" }
Expand Down

0 comments on commit 71b24b2

Please sign in to comment.