Skip to content

Commit

Permalink
Add Contributing doc
Browse files Browse the repository at this point in the history
  • Loading branch information
vdittgen committed Feb 26, 2025
1 parent 5108ce1 commit e49b5eb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 62 deletions.
61 changes: 61 additions & 0 deletions packages/dw_connector/docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -am 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## Adding a New Adapter

To add support for a new data warehouse engine, create a new adapter that implements the `DataWarehouseRepository` interface:

```ruby
module DWConnector
module Adapters
class BigQueryRepository
include DataWarehouseRepository

def initialize(table_name, conditions = nil, config = {})
@table_name = table_name
@conditions = conditions
@config = config
# Initialize connection details
end

def query(sql_query = nil)
sql_query ||= build_query
process_query_response(execute(sql_query))
end

def execute(sql_query)
# Execute query and return results
# Results will automatically be transformed according to config
end

private

def process_query_response(response)
# Transform the raw response into the expected format:
# { result_data: [[1, "test"]], result_columns: [{ "name" => "id" }, { "name" => "name" }] }
end
end
end
end
```

Then register it in the factory:

```ruby
# lib/dw_connector/repository_factory.rb
def repository_for(type)
case type
when :trino
Adapters::TrinoRepository
when :bigquery
Adapters::BigQueryRepository
else
raise ArgumentError, "Unsupported repository type: #{type}"
end
end
```
62 changes: 0 additions & 62 deletions packages/dw_connector/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,60 +131,6 @@ repository = DWConnector::RepositoryFactory.create(
# Result: { user_id: 1, total_amount: "100.50" }
```

## Adding a New Adapter

To add support for a new data warehouse engine, create a new adapter that implements the `DataWarehouseRepository` interface:

```ruby
module DWConnector
module Adapters
class BigQueryRepository
include DataWarehouseRepository

def initialize(table_name, conditions = nil, config = {})
@table_name = table_name
@conditions = conditions
@config = config
# Initialize connection details
end

def query(sql_query = nil)
sql_query ||= build_query
process_query_response(execute(sql_query))
end

def execute(sql_query)
# Execute query and return results
# Results will automatically be transformed according to config
end

private

def process_query_response(response)
# Transform the raw response into the expected format:
# { result_data: [[1, "test"]], result_columns: [{ "name" => "id" }, { "name" => "name" }] }
end
end
end
end
```

Then register it in the factory:

```ruby
# lib/dw_connector/repository_factory.rb
def repository_for(type)
case type
when :trino
Adapters::TrinoRepository
when :bigquery
Adapters::BigQueryRepository
else
raise ArgumentError, "Unsupported repository type: #{type}"
end
end
```

## Development

1. Clone the repository
Expand All @@ -199,14 +145,6 @@ end
gem "dw_connector", path: "path/to/packages/dw_connector"
```

## Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -am 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

0 comments on commit e49b5eb

Please sign in to comment.