Skip to content

Commit

Permalink
fix: add connector_query_type in spec (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
afthabvp authored Apr 9, 2024
1 parent fe55d52 commit f21bf67
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion integrations/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
multiwoven-integrations (0.1.54)
multiwoven-integrations (0.1.55)
activesupport
async-websocket
csv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ConnectorSpecification < ProtocolModel
attribute :supports_dbt, Types::Bool.default(false)
attribute :stream_type, StreamType
attribute? :supported_destination_sync_modes, Types::Array.of(DestinationSyncMode).optional
attribute? :connector_query_type, ConnectorQueryType

def to_multiwoven_message
MultiwovenMessage.new(
Expand All @@ -70,7 +71,6 @@ class Connector < ProtocolModel
attribute :name, Types::String
attribute :type, ConnectorType
attribute :connection_specification, Types::Hash
attribute :query_type, ConnectorQueryType.optional.default("raw_sql")
end

class LogMessage < ProtocolModel
Expand Down
2 changes: 1 addition & 1 deletion integrations/lib/multiwoven/integrations/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Multiwoven
module Integrations
VERSION = "0.1.54"
VERSION = "0.1.55"

ENABLED_SOURCES = %w[
Snowflake
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"documentation_url": "https://docs.multiwoven.com/integrations/sources/bigquery",
"stream_type": "dynamic",
"connector_query_type": "raw_sql",
"connection_specification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Google BigQuery",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"documentation_url": "https://docs.multiwoven.com/integrations/sources/databricks",
"stream_type": "dynamic",
"connector_query_type": "raw_sql",
"connection_specification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Databricks",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"documentation_url": "https://docs.multiwoven.com/integrations/sources/postgresql",
"stream_type": "dynamic",
"connector_query_type": "raw_sql",
"connection_specification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Postgresql",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"documentation_url": "https://docs.multiwoven.com/integrations/sources/redshift",
"stream_type": "dynamic",
"connector_query_type": "raw_sql",
"connection_specification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Amazon Redshift",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"documentation_url": "https://docs.multiwoven.com/destinations/retail/salesforce_consumer_goods_cloud",
"stream_type": "static",
"connector_query_type": "soql",
"connection_specification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Salesforce Consumer Goods Cloud",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"documentation_url": "https://docs.multiwoven.com/integrations/sources/snowflake",
"stream_type": "dynamic",
"connector_query_type": "raw_sql",
"connection_specification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Snowflake",
Expand Down
35 changes: 15 additions & 20 deletions integrations/spec/multiwoven/integrations/protocol/protocol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,34 @@ module Integrations::Protocol
"supports_normalization" => true,
"supports_dbt" => true,
"supported_destination_sync_modes" => ["insert"]
}.to_json
}

describe ".from_json" do
it "creates an instance from JSON" do
instance = ConnectorSpecification.from_json(json_data)
instance = ConnectorSpecification.from_json(json_data.to_json)
expect(instance).to be_a(ConnectorSpecification)
expect(instance.connection_specification).to eq(key: "value")
expect(instance.supports_normalization).to eq(true)
expect(instance.supports_dbt).to eq(true)
expect(instance.supported_destination_sync_modes).to eq(["insert"])
expect(instance.connector_query_type).to eq(nil)
end

it "creates an instance from JSON connector_query_type soql" do
json_data[:connector_query_type] = "soql"
instance = ConnectorSpecification.from_json(json_data.to_json)
expect(instance).to be_a(ConnectorSpecification)
expect(instance.connection_specification).to eq(key: "value")
expect(instance.supports_normalization).to eq(true)
expect(instance.supports_dbt).to eq(true)
expect(instance.supported_destination_sync_modes).to eq(["insert"])
expect(instance.connector_query_type).to eq("soql")
end
end

describe "#to_multiwoven_message" do
it "converts to a MultiwovenMessage" do
connector_spec = described_class.from_json(json_data)
connector_spec = described_class.from_json(json_data.to_json)
multiwoven_message = connector_spec.to_multiwoven_message

expect(multiwoven_message).to be_a(Multiwoven::Integrations::Protocol::MultiwovenMessage)
Expand Down Expand Up @@ -359,23 +371,6 @@ module Integrations::Protocol
expect(connector.connection_specification).to eq(key: "value")
end
end

context "connector_query_type validations" do
it "has a connector_query_type 'sql'" do
connector = Connector.new(name: "Test", type: "source", query_type: "soql", connection_specification: {})
expect(ModelQueryType.values).to include(connector.query_type)
end

it "has a connector_query_type 'soql'" do
connector = Connector.new(name: "Test", type: "destination", query_type: "soql", connection_specification: {})
expect(ModelQueryType.values).to include(connector.query_type)
end

it "has a query_type default raw_sql " do
connector = Connector.new(name: "Test", type: "destination", connection_specification: {})
expect(connector.query_type).to eq("raw_sql")
end
end
end

RSpec.describe Multiwoven::Integrations::Protocol::ControlMessage do
Expand Down

0 comments on commit f21bf67

Please sign in to comment.