Skip to main content

Popsink transformer

Project description

Transformer Library

This library provides a set of tools to transform Avro schemas into various formats such as JSON schema, SQL for Apache Flink, and PostgreSQL SQL. Additionally, it can transform data from these formats back into Avro schemas. Whether you're working with Avro schemas in your data pipeline or database schema, this library aims to simplify the conversion process for you.

Features

  • Convert Avro schema to JSON schema.
  • Generate SQL statements for Apache Flink based on Avro schema.
  • Generate PostgreSQL SQL statements based on Avro schema.
  • Generate SQLSERVER SQL statements based on Avro schema.
  • Generate CLICKHOUSE SQL statements based on Avro schema.
  • Convert a single avro type to SQL type.

Usage

Here's a quick guide on how to use the library:

1. Convert an Avro Schema to JSON schema

from popsink_transformer.transformer import Transformer

transformer = Transformer(from_source=avro_schema)
json_schema = transformer.avro_to_json.convert()
print(json_schema)

2. Generate SQL for Apache Flink from an Avro schema

from popsink_transformer.transformer import Transformer
from popsink_transformer.avro_to_sql.utils.type_converter import SqlEngine

transformer = Transformer(
    from_source=avro_schema,
    sql_engine=SqlEngine.FLINK,
)
flink_sql = transformer.avro_to_sql.convert()
print(flink_sql)

3. Generate PostgreSQL SQL from an Avro schema

from popsink_transformer.transformer import Transformer
from popsink_transformer.avro_to_sql.utils.type_converter import SqlEngine

transformer = Transformer(
    from_source=avro_schema,
    sql_engine=SqlEngine.POSTGRES,
)
postgres_sql = transformer.avro_to_sql.convert()
print(postgres_sql)

4. Convert an Avro type to SQL type

from popsink_transformer.avro_to_sql.utils.type_converter import (
    SqlEngine,
    convert_avro_type_to_sql_type,
)

postgres_sql_type = convert_avro_type_to_sql_type(
    avro_field_type="float",
    sql_engine=SqlEngine.POSTGRES
)
print(postgres_sql_type)
output: 'REAL'

5. Generate SQLSERVER SQL from an Avro schema

from popsink_transformer.transformer import Transformer
from popsink_transformer.avro_to_sql.utils.type_converter import SqlEngine

transformer = Transformer(
    from_source=avro_schema,
    sql_engine=SqlEngine.SQLSERVER,
)
sqlserver_sql = transformer.avro_to_sql.convert()
print(sqlserver_sql)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

popsink_transformer-2.2.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

popsink_transformer-2.2.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file popsink_transformer-2.2.0.tar.gz.

File metadata

  • Download URL: popsink_transformer-2.2.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.5 Darwin/23.4.0

File hashes

Hashes for popsink_transformer-2.2.0.tar.gz
Algorithm Hash digest
SHA256 ddad6f23bceb82bd702503e28aa5bb86a7702f5635948e3ea2bd0f230b4002c4
MD5 1747955fa81c1b0445af60218d604d33
BLAKE2b-256 1a9a29144f0de908451e3d5765a3e5835282b9819f23f2debdd2ba81244c3c36

See more details on using hashes here.

File details

Details for the file popsink_transformer-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for popsink_transformer-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da6a948355b7bc6ff057fa0079fcb4406abab209dd92f3f7046bf8ca5d11aa92
MD5 0cbb05123c6fd46b178bd3c62832057f
BLAKE2b-256 d216a3cc0585db11e81d1f38a0b9ebba9d1ceddcb8e63e9618806edb5b41cd82

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page