avrotize 2.21.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- avrotize/__init__.py +66 -0
- avrotize/__main__.py +6 -0
- avrotize/_version.py +34 -0
- avrotize/asn1toavro.py +160 -0
- avrotize/avrotize.py +152 -0
- avrotize/avrotocpp/CMakeLists.txt.jinja +77 -0
- avrotize/avrotocpp/build.bat.jinja +7 -0
- avrotize/avrotocpp/build.sh.jinja +7 -0
- avrotize/avrotocpp/dataclass_body.jinja +108 -0
- avrotize/avrotocpp/vcpkg.json.jinja +21 -0
- avrotize/avrotocpp.py +483 -0
- avrotize/avrotocsharp/README.md.jinja +166 -0
- avrotize/avrotocsharp/class_test.cs.jinja +266 -0
- avrotize/avrotocsharp/dataclass_core.jinja +293 -0
- avrotize/avrotocsharp/enum_test.cs.jinja +20 -0
- avrotize/avrotocsharp/project.csproj.jinja +30 -0
- avrotize/avrotocsharp/project.sln.jinja +34 -0
- avrotize/avrotocsharp/run_coverage.ps1.jinja +98 -0
- avrotize/avrotocsharp/run_coverage.sh.jinja +149 -0
- avrotize/avrotocsharp/testproject.csproj.jinja +19 -0
- avrotize/avrotocsharp.py +1180 -0
- avrotize/avrotocsv.py +121 -0
- avrotize/avrotodatapackage.py +173 -0
- avrotize/avrotodb.py +1383 -0
- avrotize/avrotogo/go_enum.jinja +12 -0
- avrotize/avrotogo/go_helpers.jinja +31 -0
- avrotize/avrotogo/go_struct.jinja +151 -0
- avrotize/avrotogo/go_test.jinja +47 -0
- avrotize/avrotogo/go_union.jinja +38 -0
- avrotize/avrotogo.py +476 -0
- avrotize/avrotographql.py +197 -0
- avrotize/avrotoiceberg.py +210 -0
- avrotize/avrotojava/class_test.java.jinja +212 -0
- avrotize/avrotojava/enum_test.java.jinja +21 -0
- avrotize/avrotojava/testproject.pom.jinja +54 -0
- avrotize/avrotojava.py +2156 -0
- avrotize/avrotojs.py +250 -0
- avrotize/avrotojsons.py +481 -0
- avrotize/avrotojstruct.py +345 -0
- avrotize/avrotokusto.py +364 -0
- avrotize/avrotomd/README.md.jinja +49 -0
- avrotize/avrotomd.py +137 -0
- avrotize/avrotools.py +168 -0
- avrotize/avrotoparquet.py +208 -0
- avrotize/avrotoproto.py +359 -0
- avrotize/avrotopython/dataclass_core.jinja +241 -0
- avrotize/avrotopython/enum_core.jinja +87 -0
- avrotize/avrotopython/pyproject_toml.jinja +18 -0
- avrotize/avrotopython/test_class.jinja +97 -0
- avrotize/avrotopython/test_enum.jinja +23 -0
- avrotize/avrotopython.py +626 -0
- avrotize/avrotorust/dataclass_enum.rs.jinja +74 -0
- avrotize/avrotorust/dataclass_struct.rs.jinja +204 -0
- avrotize/avrotorust/dataclass_union.rs.jinja +105 -0
- avrotize/avrotorust.py +435 -0
- avrotize/avrotots/class_core.ts.jinja +140 -0
- avrotize/avrotots/class_test.ts.jinja +77 -0
- avrotize/avrotots/enum_core.ts.jinja +46 -0
- avrotize/avrotots/gitignore.jinja +34 -0
- avrotize/avrotots/index.ts.jinja +0 -0
- avrotize/avrotots/package.json.jinja +23 -0
- avrotize/avrotots/tsconfig.json.jinja +21 -0
- avrotize/avrotots.py +687 -0
- avrotize/avrotoxsd.py +344 -0
- avrotize/cddltostructure.py +1841 -0
- avrotize/commands.json +3496 -0
- avrotize/common.py +834 -0
- avrotize/constants.py +87 -0
- avrotize/csvtoavro.py +132 -0
- avrotize/datapackagetoavro.py +76 -0
- avrotize/dependencies/cpp/vcpkg/vcpkg.json +19 -0
- avrotize/dependencies/cs/net90/dependencies.csproj +29 -0
- avrotize/dependencies/go/go121/go.mod +6 -0
- avrotize/dependencies/java/jdk21/pom.xml +91 -0
- avrotize/dependencies/python/py312/requirements.txt +13 -0
- avrotize/dependencies/rust/stable/Cargo.toml +17 -0
- avrotize/dependencies/typescript/node22/package.json +16 -0
- avrotize/dependency_resolver.py +348 -0
- avrotize/dependency_version.py +432 -0
- avrotize/generic/generic.avsc +57 -0
- avrotize/jsonstoavro.py +2167 -0
- avrotize/jsonstostructure.py +2864 -0
- avrotize/jstructtoavro.py +878 -0
- avrotize/kstructtoavro.py +93 -0
- avrotize/kustotoavro.py +455 -0
- avrotize/openapitostructure.py +717 -0
- avrotize/parquettoavro.py +157 -0
- avrotize/proto2parser.py +498 -0
- avrotize/proto3parser.py +403 -0
- avrotize/prototoavro.py +382 -0
- avrotize/prototypes/any.avsc +19 -0
- avrotize/prototypes/api.avsc +106 -0
- avrotize/prototypes/duration.avsc +20 -0
- avrotize/prototypes/field_mask.avsc +18 -0
- avrotize/prototypes/struct.avsc +60 -0
- avrotize/prototypes/timestamp.avsc +20 -0
- avrotize/prototypes/type.avsc +253 -0
- avrotize/prototypes/wrappers.avsc +117 -0
- avrotize/structuretocddl.py +597 -0
- avrotize/structuretocpp/CMakeLists.txt.jinja +76 -0
- avrotize/structuretocpp/build.bat.jinja +3 -0
- avrotize/structuretocpp/build.sh.jinja +3 -0
- avrotize/structuretocpp/dataclass_body.jinja +50 -0
- avrotize/structuretocpp/vcpkg.json.jinja +11 -0
- avrotize/structuretocpp.py +697 -0
- avrotize/structuretocsharp/class_test.cs.jinja +180 -0
- avrotize/structuretocsharp/dataclass_core.jinja +156 -0
- avrotize/structuretocsharp/enum_test.cs.jinja +36 -0
- avrotize/structuretocsharp/json_structure_converters.cs.jinja +399 -0
- avrotize/structuretocsharp/program.cs.jinja +49 -0
- avrotize/structuretocsharp/project.csproj.jinja +17 -0
- avrotize/structuretocsharp/project.sln.jinja +34 -0
- avrotize/structuretocsharp/testproject.csproj.jinja +18 -0
- avrotize/structuretocsharp/tuple_converter.cs.jinja +121 -0
- avrotize/structuretocsharp.py +2295 -0
- avrotize/structuretocsv.py +365 -0
- avrotize/structuretodatapackage.py +659 -0
- avrotize/structuretodb.py +1125 -0
- avrotize/structuretogo/go_enum.jinja +12 -0
- avrotize/structuretogo/go_helpers.jinja +26 -0
- avrotize/structuretogo/go_interface.jinja +18 -0
- avrotize/structuretogo/go_struct.jinja +187 -0
- avrotize/structuretogo/go_test.jinja +70 -0
- avrotize/structuretogo.py +729 -0
- avrotize/structuretographql.py +502 -0
- avrotize/structuretoiceberg.py +355 -0
- avrotize/structuretojava/choice_core.jinja +34 -0
- avrotize/structuretojava/class_core.jinja +23 -0
- avrotize/structuretojava/enum_core.jinja +18 -0
- avrotize/structuretojava/equals_hashcode.jinja +30 -0
- avrotize/structuretojava/pom.xml.jinja +26 -0
- avrotize/structuretojava/tuple_core.jinja +49 -0
- avrotize/structuretojava.py +938 -0
- avrotize/structuretojs/class_core.js.jinja +33 -0
- avrotize/structuretojs/enum_core.js.jinja +10 -0
- avrotize/structuretojs/package.json.jinja +12 -0
- avrotize/structuretojs/test_class.js.jinja +84 -0
- avrotize/structuretojs/test_enum.js.jinja +58 -0
- avrotize/structuretojs/test_runner.js.jinja +45 -0
- avrotize/structuretojs.py +657 -0
- avrotize/structuretojsons.py +498 -0
- avrotize/structuretokusto.py +639 -0
- avrotize/structuretomd/README.md.jinja +204 -0
- avrotize/structuretomd.py +322 -0
- avrotize/structuretoproto.py +764 -0
- avrotize/structuretopython/dataclass_core.jinja +363 -0
- avrotize/structuretopython/enum_core.jinja +45 -0
- avrotize/structuretopython/map_alias.jinja +21 -0
- avrotize/structuretopython/pyproject_toml.jinja +23 -0
- avrotize/structuretopython/test_class.jinja +103 -0
- avrotize/structuretopython/test_enum.jinja +34 -0
- avrotize/structuretopython.py +799 -0
- avrotize/structuretorust/dataclass_enum.rs.jinja +63 -0
- avrotize/structuretorust/dataclass_struct.rs.jinja +121 -0
- avrotize/structuretorust/dataclass_union.rs.jinja +81 -0
- avrotize/structuretorust.py +714 -0
- avrotize/structuretots/class_core.ts.jinja +78 -0
- avrotize/structuretots/enum_core.ts.jinja +6 -0
- avrotize/structuretots/gitignore.jinja +8 -0
- avrotize/structuretots/index.ts.jinja +1 -0
- avrotize/structuretots/package.json.jinja +39 -0
- avrotize/structuretots/test_class.ts.jinja +35 -0
- avrotize/structuretots/tsconfig.json.jinja +21 -0
- avrotize/structuretots.py +740 -0
- avrotize/structuretoxsd.py +679 -0
- avrotize/xsdtoavro.py +413 -0
- avrotize-2.21.1.dist-info/METADATA +1319 -0
- avrotize-2.21.1.dist-info/RECORD +171 -0
- avrotize-2.21.1.dist-info/WHEEL +4 -0
- avrotize-2.21.1.dist-info/entry_points.txt +3 -0
- avrotize-2.21.1.dist-info/licenses/LICENSE +201 -0
avrotize/constants.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Constants for the avrotize package.
|
|
2
|
+
|
|
3
|
+
These constants are now derived from central dependency files in avrotize/dependencies/
|
|
4
|
+
which are monitored by Dependabot. This ensures versions stay up-to-date.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from avrotize.dependency_version import get_dependency_version
|
|
8
|
+
|
|
9
|
+
# Java/JVM dependencies
|
|
10
|
+
try:
|
|
11
|
+
AVRO_VERSION = get_dependency_version('java', 'jdk21', 'org.apache.avro:avro')
|
|
12
|
+
except ValueError:
|
|
13
|
+
AVRO_VERSION = '1.12.0' # Fallback
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
JACKSON_VERSION = get_dependency_version('java', 'jdk21', 'com.fasterxml.jackson.core:jackson-core')
|
|
17
|
+
except ValueError:
|
|
18
|
+
JACKSON_VERSION = '2.18.2' # Fallback
|
|
19
|
+
|
|
20
|
+
JDK_VERSION = '21'
|
|
21
|
+
|
|
22
|
+
# C# dependencies
|
|
23
|
+
try:
|
|
24
|
+
CSHARP_AVRO_VERSION = get_dependency_version('cs', 'net90', 'Apache.Avro')
|
|
25
|
+
except ValueError:
|
|
26
|
+
CSHARP_AVRO_VERSION = '1.12.0'
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
NEWTONSOFT_JSON_VERSION = get_dependency_version('cs', 'net90', 'Newtonsoft.Json')
|
|
30
|
+
except ValueError:
|
|
31
|
+
NEWTONSOFT_JSON_VERSION = '13.0.3'
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
SYSTEM_TEXT_JSON_VERSION = get_dependency_version('cs', 'net90', 'System.Text.Json')
|
|
35
|
+
except ValueError:
|
|
36
|
+
SYSTEM_TEXT_JSON_VERSION = '9.0.3'
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
SYSTEM_MEMORY_DATA_VERSION = get_dependency_version('cs', 'net90', 'System.Memory.Data')
|
|
40
|
+
except ValueError:
|
|
41
|
+
SYSTEM_MEMORY_DATA_VERSION = '9.0.3'
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
PROTOBUF_NET_VERSION = get_dependency_version('cs', 'net90', 'protobuf-net')
|
|
45
|
+
except ValueError:
|
|
46
|
+
PROTOBUF_NET_VERSION = '3.2.30'
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
NUNIT_VERSION = get_dependency_version('cs', 'net90', 'NUnit')
|
|
50
|
+
except ValueError:
|
|
51
|
+
NUNIT_VERSION = '4.3.2'
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
NUNIT_ADAPTER_VERSION = get_dependency_version('cs', 'net90', 'NUnit3TestAdapter')
|
|
55
|
+
except ValueError:
|
|
56
|
+
NUNIT_ADAPTER_VERSION = '5.0.0'
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
MSTEST_SDK_VERSION = get_dependency_version('cs', 'net90', 'Microsoft.NET.Test.Sdk')
|
|
60
|
+
except ValueError:
|
|
61
|
+
MSTEST_SDK_VERSION = '17.13.0'
|
|
62
|
+
|
|
63
|
+
try:
|
|
64
|
+
COVERLET_VERSION = get_dependency_version('cs', 'net90', 'coverlet.collector')
|
|
65
|
+
except ValueError:
|
|
66
|
+
COVERLET_VERSION = '6.0.4'
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
MSGPACK_VERSION = get_dependency_version('cs', 'net90', 'MessagePack')
|
|
70
|
+
except ValueError:
|
|
71
|
+
MSGPACK_VERSION = '2.5.187'
|
|
72
|
+
|
|
73
|
+
# Java test dependencies
|
|
74
|
+
try:
|
|
75
|
+
JUNIT_VERSION = get_dependency_version('java', 'jdk21', 'org.junit.jupiter:junit-jupiter-api')
|
|
76
|
+
except ValueError:
|
|
77
|
+
JUNIT_VERSION = '5.11.4'
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
MAVEN_SUREFIRE_VERSION = get_dependency_version('java', 'jdk21', 'org.apache.maven.plugins:maven-surefire-plugin')
|
|
81
|
+
except ValueError:
|
|
82
|
+
MAVEN_SUREFIRE_VERSION = '3.5.2'
|
|
83
|
+
|
|
84
|
+
try:
|
|
85
|
+
MAVEN_COMPILER_VERSION = get_dependency_version('java', 'jdk21', 'org.apache.maven.plugins:maven-compiler-plugin')
|
|
86
|
+
except ValueError:
|
|
87
|
+
MAVEN_COMPILER_VERSION = '3.13.0'
|
avrotize/csvtoavro.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
Module to convert CSV schema to Avro schema.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
from avrotize.common import pascal
|
|
11
|
+
|
|
12
|
+
class CSVToAvroConverter:
|
|
13
|
+
"""
|
|
14
|
+
Class to convert CSV schema to Avro schema.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, csv_file_path, avro_schema_path, namespace=""):
|
|
18
|
+
"""
|
|
19
|
+
Initialize the converter with file paths and namespace.
|
|
20
|
+
|
|
21
|
+
:param csv_file_path: Path to the CSV file.
|
|
22
|
+
:param avro_schema_path: Path to save the Avro schema file.
|
|
23
|
+
:param csv_schema_path: Optional path to CSV schema file.
|
|
24
|
+
:param namespace: Namespace for Avro records.
|
|
25
|
+
"""
|
|
26
|
+
self.csv_file_path = csv_file_path
|
|
27
|
+
self.avro_schema_path = avro_schema_path
|
|
28
|
+
self.namespace = namespace
|
|
29
|
+
|
|
30
|
+
def convert(self):
|
|
31
|
+
"""
|
|
32
|
+
Convert CSV schema to Avro schema and save to file.
|
|
33
|
+
"""
|
|
34
|
+
schema = self.infer_schema()
|
|
35
|
+
|
|
36
|
+
# Infer the name of the schema from the CSV file name
|
|
37
|
+
schema_name = os.path.splitext(os.path.basename(self.csv_file_path))[0].replace(" ", "_")
|
|
38
|
+
|
|
39
|
+
avro_schema = {}
|
|
40
|
+
avro_schema["type"] = "record"
|
|
41
|
+
avro_schema["name"] = schema_name
|
|
42
|
+
if self.namespace:
|
|
43
|
+
avro_schema["namespace"] = self.namespace
|
|
44
|
+
avro_schema["fields"] = schema
|
|
45
|
+
|
|
46
|
+
with open(self.avro_schema_path, "w", encoding="utf-8") as file:
|
|
47
|
+
json.dump(avro_schema, file, indent=2)
|
|
48
|
+
|
|
49
|
+
def infer_schema(self):
|
|
50
|
+
"""
|
|
51
|
+
Infer the schema from CSV headers or data.
|
|
52
|
+
:return: List of fields in Avro schema format.
|
|
53
|
+
"""
|
|
54
|
+
df = pd.read_csv(self.csv_file_path)
|
|
55
|
+
schema = []
|
|
56
|
+
for column in df.columns:
|
|
57
|
+
avro_field = {
|
|
58
|
+
"name": pascal(column),
|
|
59
|
+
"type": self.infer_avro_type(df[column])
|
|
60
|
+
}
|
|
61
|
+
if avro_field["name"] != column:
|
|
62
|
+
avro_field["altnames"] = { "csv": column}
|
|
63
|
+
schema.append(avro_field)
|
|
64
|
+
return schema
|
|
65
|
+
|
|
66
|
+
def infer_avro_type(self, series):
|
|
67
|
+
"""
|
|
68
|
+
Infer Avro type from pandas series.
|
|
69
|
+
:param series: Pandas series to infer type from.
|
|
70
|
+
:return: Avro type as string.
|
|
71
|
+
"""
|
|
72
|
+
if pd.api.types.is_integer_dtype(series):
|
|
73
|
+
return "int"
|
|
74
|
+
if pd.api.types.is_float_dtype(series):
|
|
75
|
+
return "double"
|
|
76
|
+
if pd.api.types.is_bool_dtype(series):
|
|
77
|
+
return "boolean"
|
|
78
|
+
if pd.api.types.is_datetime64_any_dtype(series):
|
|
79
|
+
return {"type": "long", "logicalType": "timestamp-millis"}
|
|
80
|
+
if pd.api.types.is_object_dtype(series):
|
|
81
|
+
return "string"
|
|
82
|
+
return "string"
|
|
83
|
+
|
|
84
|
+
def map_csv_type_to_avro(self, csv_type):
|
|
85
|
+
"""
|
|
86
|
+
Map CSV type to Avro type.
|
|
87
|
+
:param csv_type: CSV type as string.
|
|
88
|
+
:return: Avro type as string.
|
|
89
|
+
"""
|
|
90
|
+
type_mapping = {
|
|
91
|
+
"string": "string",
|
|
92
|
+
"number": "double",
|
|
93
|
+
"integer": "int",
|
|
94
|
+
"boolean": "boolean",
|
|
95
|
+
"date": {"type": "int", "logicalType": "date"},
|
|
96
|
+
"timestamp": {"type": "long", "logicalType": "timestamp-millis"}
|
|
97
|
+
}
|
|
98
|
+
return type_mapping.get(csv_type.lower(), "string")
|
|
99
|
+
|
|
100
|
+
def handle_string_format(self, format_type):
|
|
101
|
+
"""
|
|
102
|
+
Handle string format types.
|
|
103
|
+
:param format_type: Format type as string.
|
|
104
|
+
:return: Avro type as string or dict.
|
|
105
|
+
"""
|
|
106
|
+
format_mapping = {
|
|
107
|
+
"email": "string",
|
|
108
|
+
"uri": "string",
|
|
109
|
+
"uuid": "string",
|
|
110
|
+
"ipv4": "string",
|
|
111
|
+
"ipv6": "string",
|
|
112
|
+
"hostname": "string",
|
|
113
|
+
"datetime": {"type": "long", "logicalType": "timestamp-millis"}
|
|
114
|
+
}
|
|
115
|
+
return format_mapping.get(format_type.lower(), "string")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def convert_csv_to_avro(csv_file_path, avro_file_path, namespace=""):
|
|
119
|
+
"""
|
|
120
|
+
Convert a CSV file to an Avro schema file.
|
|
121
|
+
|
|
122
|
+
:param csv_file_path: Path to the CSV file.
|
|
123
|
+
:param avro_file_path: Path to save the Avro schema file.
|
|
124
|
+
:param namespace: Namespace for Avro records.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
if not os.path.exists(csv_file_path):
|
|
128
|
+
raise FileNotFoundError(f"CSV file not found at: {csv_file_path}")
|
|
129
|
+
|
|
130
|
+
converter = CSVToAvroConverter(
|
|
131
|
+
csv_file_path, avro_file_path, namespace)
|
|
132
|
+
converter.convert()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Convert a Data Package to an Avro schema."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
from typing import Dict, List
|
|
6
|
+
from datapackage import Package
|
|
7
|
+
|
|
8
|
+
JsonNode = Dict[str, 'JsonNode'] | List['JsonNode'] | str | bool | int | None
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DataPackageToAvroConverter:
|
|
12
|
+
"""Class to convert Data Package to Avro schema."""
|
|
13
|
+
|
|
14
|
+
def convert_datapackage_to_avro(self, datapackage_path, avro_schema_path):
|
|
15
|
+
"""Convert a Data Package to an Avro schema."""
|
|
16
|
+
package = Package(datapackage_path)
|
|
17
|
+
resources = package.resources
|
|
18
|
+
|
|
19
|
+
avro_schemas = []
|
|
20
|
+
|
|
21
|
+
for resource in resources:
|
|
22
|
+
table_name = resource.descriptor['name']
|
|
23
|
+
fields = resource.descriptor['schema']['fields']
|
|
24
|
+
|
|
25
|
+
avro_fields = []
|
|
26
|
+
for field in fields:
|
|
27
|
+
avro_field = {
|
|
28
|
+
"name": field["name"],
|
|
29
|
+
"type": self.convert_datapackage_type_to_avro_type(field["type"])
|
|
30
|
+
}
|
|
31
|
+
avro_fields.append(avro_field)
|
|
32
|
+
|
|
33
|
+
avro_schema = {
|
|
34
|
+
"type": "record",
|
|
35
|
+
"name": table_name,
|
|
36
|
+
"fields": avro_fields
|
|
37
|
+
}
|
|
38
|
+
avro_schemas.append(avro_schema)
|
|
39
|
+
|
|
40
|
+
# If there's only one schema, write it directly
|
|
41
|
+
if len(avro_schemas) == 1:
|
|
42
|
+
avro_schema = avro_schemas[0]
|
|
43
|
+
else:
|
|
44
|
+
# If there are multiple schemas, create a union
|
|
45
|
+
avro_schema = avro_schemas
|
|
46
|
+
|
|
47
|
+
with open(avro_schema_path, "w", encoding="utf-8") as f:
|
|
48
|
+
json.dump(avro_schema, f, indent=2)
|
|
49
|
+
|
|
50
|
+
def convert_datapackage_type_to_avro_type(self, datapackage_type):
|
|
51
|
+
"""Convert a Data Package type to an Avro type."""
|
|
52
|
+
if datapackage_type == "string":
|
|
53
|
+
return "string"
|
|
54
|
+
elif datapackage_type == "number":
|
|
55
|
+
return "double"
|
|
56
|
+
elif datapackage_type == "integer":
|
|
57
|
+
return "int"
|
|
58
|
+
elif datapackage_type == "boolean":
|
|
59
|
+
return "boolean"
|
|
60
|
+
elif datapackage_type == "array":
|
|
61
|
+
return {"type": "array", "items": "string"}
|
|
62
|
+
elif datapackage_type == "object":
|
|
63
|
+
return {"type": "map", "values": "string"}
|
|
64
|
+
else:
|
|
65
|
+
print(f"WARNING: Unsupported data package type: {datapackage_type}")
|
|
66
|
+
return "string"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def convert_datapackage_to_avro(datapackage_path, avro_schema_path):
|
|
70
|
+
"""Convert a Data Package to an Avro schema."""
|
|
71
|
+
converter = DataPackageToAvroConverter()
|
|
72
|
+
converter.convert_datapackage_to_avro(datapackage_path, avro_schema_path)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# Example usage:
|
|
76
|
+
# convert_datapackage_to_avro("datapackage.json", "schema.avsc")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Central dependency versions for Avrotize C++ code generation templates. This file is monitored by Dependabot.",
|
|
3
|
+
"name": "avrotize-dependencies",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
{
|
|
7
|
+
"name": "avro-cpp",
|
|
8
|
+
"version>=": "1.11.1"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "nlohmann-json",
|
|
12
|
+
"version>=": "3.11.3"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "gtest",
|
|
16
|
+
"version>=": "1.15.2"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Central dependency file for .NET 9.0 code generation templates.
|
|
4
|
+
Dependabot will detect and propose updates to these dependencies.
|
|
5
|
+
The dependency() function in templates reads from this file.
|
|
6
|
+
-->
|
|
7
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
8
|
+
<PropertyGroup>
|
|
9
|
+
<TargetFramework>net9.0</TargetFramework>
|
|
10
|
+
<Nullable>enable</Nullable>
|
|
11
|
+
</PropertyGroup>
|
|
12
|
+
|
|
13
|
+
<!-- Serialization -->
|
|
14
|
+
<ItemGroup>
|
|
15
|
+
<PackageReference Include="Apache.Avro" Version="1.12.0" />
|
|
16
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
|
17
|
+
<PackageReference Include="System.Text.Json" Version="9.0.3" />
|
|
18
|
+
<PackageReference Include="System.Memory.Data" Version="9.0.3" />
|
|
19
|
+
<PackageReference Include="protobuf-net" Version="3.2.30" />
|
|
20
|
+
<PackageReference Include="MessagePack" Version="3.1.4" />
|
|
21
|
+
</ItemGroup>
|
|
22
|
+
|
|
23
|
+
<!-- Testing -->
|
|
24
|
+
<ItemGroup>
|
|
25
|
+
<PackageReference Include="NUnit" Version="4.4.0" />
|
|
26
|
+
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
|
|
27
|
+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
|
|
28
|
+
</ItemGroup>
|
|
29
|
+
</Project>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Central dependency file for Java JDK 21 code generation templates.
|
|
4
|
+
Dependabot will detect and propose updates to these dependencies.
|
|
5
|
+
The dependency() function in templates reads from this file.
|
|
6
|
+
|
|
7
|
+
Note: XML namespace is intentionally omitted for simpler parsing.
|
|
8
|
+
Dependabot still recognizes dependencies without the namespace.
|
|
9
|
+
-->
|
|
10
|
+
<project>
|
|
11
|
+
<modelVersion>4.0.0</modelVersion>
|
|
12
|
+
|
|
13
|
+
<groupId>io.avrotize</groupId>
|
|
14
|
+
<artifactId>dependencies</artifactId>
|
|
15
|
+
<version>1.0-SNAPSHOT</version>
|
|
16
|
+
<packaging>pom</packaging>
|
|
17
|
+
|
|
18
|
+
<name>Avrotize Java Dependencies Reference</name>
|
|
19
|
+
<description>Reference project for dependency version management</description>
|
|
20
|
+
|
|
21
|
+
<properties>
|
|
22
|
+
<maven.compiler.source>21</maven.compiler.source>
|
|
23
|
+
<maven.compiler.target>21</maven.compiler.target>
|
|
24
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
25
|
+
</properties>
|
|
26
|
+
|
|
27
|
+
<dependencies>
|
|
28
|
+
<!-- Apache Avro -->
|
|
29
|
+
<dependency>
|
|
30
|
+
<groupId>org.apache.avro</groupId>
|
|
31
|
+
<artifactId>avro</artifactId>
|
|
32
|
+
<version>1.12.1</version>
|
|
33
|
+
</dependency>
|
|
34
|
+
|
|
35
|
+
<!-- Jackson BOM for version consistency -->
|
|
36
|
+
<dependency>
|
|
37
|
+
<groupId>com.fasterxml.jackson</groupId>
|
|
38
|
+
<artifactId>jackson-bom</artifactId>
|
|
39
|
+
<version>2.20.1</version>
|
|
40
|
+
<type>pom</type>
|
|
41
|
+
<scope>import</scope>
|
|
42
|
+
</dependency>
|
|
43
|
+
<dependency>
|
|
44
|
+
<groupId>com.fasterxml.jackson.core</groupId>
|
|
45
|
+
<artifactId>jackson-core</artifactId>
|
|
46
|
+
<version>2.18.2</version>
|
|
47
|
+
</dependency>
|
|
48
|
+
<dependency>
|
|
49
|
+
<groupId>com.fasterxml.jackson.core</groupId>
|
|
50
|
+
<artifactId>jackson-databind</artifactId>
|
|
51
|
+
<version>2.20.1</version>
|
|
52
|
+
</dependency>
|
|
53
|
+
<dependency>
|
|
54
|
+
<groupId>com.fasterxml.jackson.core</groupId>
|
|
55
|
+
<artifactId>jackson-annotations</artifactId>
|
|
56
|
+
<version>2.20</version>
|
|
57
|
+
</dependency>
|
|
58
|
+
|
|
59
|
+
<!-- Testing - JUnit 5 -->
|
|
60
|
+
<dependency>
|
|
61
|
+
<groupId>org.junit.jupiter</groupId>
|
|
62
|
+
<artifactId>junit-jupiter</artifactId>
|
|
63
|
+
<version>6.0.1</version>
|
|
64
|
+
<scope>test</scope>
|
|
65
|
+
</dependency>
|
|
66
|
+
<dependency>
|
|
67
|
+
<groupId>org.junit.jupiter</groupId>
|
|
68
|
+
<artifactId>junit-jupiter-api</artifactId>
|
|
69
|
+
<version>6.0.1</version>
|
|
70
|
+
<scope>test</scope>
|
|
71
|
+
</dependency>
|
|
72
|
+
<dependency>
|
|
73
|
+
<groupId>org.junit.jupiter</groupId>
|
|
74
|
+
<artifactId>junit-jupiter-engine</artifactId>
|
|
75
|
+
<version>6.0.1</version>
|
|
76
|
+
<scope>test</scope>
|
|
77
|
+
</dependency>
|
|
78
|
+
|
|
79
|
+
<!-- Maven Plugins -->
|
|
80
|
+
<dependency>
|
|
81
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
82
|
+
<artifactId>maven-surefire-plugin</artifactId>
|
|
83
|
+
<version>3.5.4</version>
|
|
84
|
+
</dependency>
|
|
85
|
+
<dependency>
|
|
86
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
87
|
+
<artifactId>maven-compiler-plugin</artifactId>
|
|
88
|
+
<version>3.14.1</version>
|
|
89
|
+
</dependency>
|
|
90
|
+
</dependencies>
|
|
91
|
+
</project>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Central dependency versions for Avrotize Python code generation templates
|
|
2
|
+
# This file is monitored by Dependabot and read by the dependency() function in templates
|
|
3
|
+
|
|
4
|
+
# Runtime dependencies
|
|
5
|
+
avro>=1.12.0
|
|
6
|
+
fastavro>=1.10.0
|
|
7
|
+
confluent-kafka>=2.6.1
|
|
8
|
+
dataclasses-json>=0.6.7
|
|
9
|
+
|
|
10
|
+
# Development dependencies
|
|
11
|
+
pytest>=8.3.4
|
|
12
|
+
mypy>=1.13.0
|
|
13
|
+
pylint>=3.3.2
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Central dependency versions for Avrotize Rust code generation templates
|
|
2
|
+
# This file is monitored by Dependabot and read by the dependency() function in templates
|
|
3
|
+
|
|
4
|
+
[package]
|
|
5
|
+
name = "avrotize-dependencies"
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
edition = "2021"
|
|
8
|
+
publish = false
|
|
9
|
+
|
|
10
|
+
[dependencies]
|
|
11
|
+
apache-avro = "0.21.0"
|
|
12
|
+
serde = { version = "1.0.215", features = ["derive"] }
|
|
13
|
+
serde_json = "1.0.133"
|
|
14
|
+
chrono = { version = "0.4.38", features = ["serde"] }
|
|
15
|
+
uuid = { version = "1.11.0", features = ["v4", "serde"] }
|
|
16
|
+
|
|
17
|
+
[dev-dependencies]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "avrotize-dependencies",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Central dependency versions for Avrotize TypeScript code generation templates",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"avsc": "^5.7.7",
|
|
8
|
+
"kafkajs": "^2.2.4"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^24.10.1",
|
|
12
|
+
"typescript": "^5.7.2",
|
|
13
|
+
"jest": "^30.2.0",
|
|
14
|
+
"@types/jest": "^30.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|