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.3.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

popsink_transformer-2.3.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: popsink_transformer-2.3.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for popsink_transformer-2.3.1.tar.gz
Algorithm Hash digest
SHA256 6f9b53ac16a1ec9405d7beec2e1dde3225d7dd2f24a8b7fcc3767293f795ad00
MD5 2db55ccdfd5508073b362fb06931111a
BLAKE2b-256 381f8d87778daaf7e55384ac1f340ca7a48b58ae54d882a4bc15428ccbe4ed0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for popsink_transformer-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99c233a77685a47985c1a8c872a0eb7a47b7b404fb95db0c8353a6a6d85c029e
MD5 2993b0017356305989eb22610ccea437
BLAKE2b-256 f23106f644c9f81193183e6801a7c34bb2749d976898b0f9a19f98860fc253dc

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