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.
  • 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'

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

Uploaded Source

Built Distribution

popsink_transformer-2.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for popsink_transformer-2.0.0.tar.gz
Algorithm Hash digest
SHA256 781a45b2a13c6cbd091ed36d154e861abc0f070053e63bebde59e81b7f15358b
MD5 3fe88bdb76c2d558d22777f7a176c471
BLAKE2b-256 b705c307748487cbf81955f0ca1d4ddd5f0dc276e7dd528c3984220d932aad1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for popsink_transformer-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9af69ac32ba72aa4ee5e5c35e0721a90bed2253b6f0adbc6356538eb8bcc4fd7
MD5 577c7b0513e3b3a26d965a5279fba30b
BLAKE2b-256 6f15aeaebce3581c16b4640e87090140ea57c2cff0256be68c0cbd1a0068b021

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