Skip to content

Commit 2e5196e

Browse files
authored
Test avro and json dataset schema. (#41699)
1 parent 0c4198b commit 2e5196e

File tree

5 files changed

+425
-1
lines changed

5 files changed

+425
-1
lines changed

sdk/datafactory/Azure.ResourceManager.DataFactory/api/Azure.ResourceManager.DataFactory.netstandard2.0.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ public AvroDataset(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceRe
10991099
public Azure.Core.Expressions.DataFactory.DataFactoryElement<string> AvroCompressionCodec { get { throw null; } set { } }
11001100
public int? AvroCompressionLevel { get { throw null; } set { } }
11011101
public Azure.ResourceManager.DataFactory.Models.DatasetLocation DataLocation { get { throw null; } set { } }
1102+
public new Azure.Core.Expressions.DataFactory.DataFactoryElement<System.BinaryData> Schema { get { throw null; } set { } }
11021103
Azure.ResourceManager.DataFactory.Models.AvroDataset System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.DataFactory.Models.AvroDataset>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
11031104
void System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.DataFactory.Models.AvroDataset>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
11041105
Azure.ResourceManager.DataFactory.Models.AvroDataset System.ClientModel.Primitives.IPersistableModel<Azure.ResourceManager.DataFactory.Models.AvroDataset>.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
@@ -6486,6 +6487,7 @@ public JsonDataset(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceRe
64866487
public Azure.ResourceManager.DataFactory.Models.DatasetCompression Compression { get { throw null; } set { } }
64876488
public Azure.ResourceManager.DataFactory.Models.DatasetLocation DataLocation { get { throw null; } set { } }
64886489
public Azure.Core.Expressions.DataFactory.DataFactoryElement<string> EncodingName { get { throw null; } set { } }
6490+
public new Azure.Core.Expressions.DataFactory.DataFactoryElement<System.BinaryData> Schema { get { throw null; } set { } }
64896491
Azure.ResourceManager.DataFactory.Models.JsonDataset System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.DataFactory.Models.JsonDataset>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
64906492
void System.ClientModel.Primitives.IJsonModel<Azure.ResourceManager.DataFactory.Models.JsonDataset>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
64916493
Azure.ResourceManager.DataFactory.Models.JsonDataset System.ClientModel.Primitives.IPersistableModel<Azure.ResourceManager.DataFactory.Models.JsonDataset>.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }

sdk/datafactory/Azure.ResourceManager.DataFactory/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/datafactory/Azure.ResourceManager.DataFactory",
5-
"Tag": "net/datafactory/Azure.ResourceManager.DataFactory_23a911dae9"
5+
"Tag": "net/datafactory/Azure.ResourceManager.DataFactory_8bebc7d7e6"
66
}
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#nullable disable
5+
6+
using System;
7+
using System.Collections.Generic;
8+
using System.ComponentModel;
9+
using System.Text.Json;
10+
using Azure.Core;
11+
using Azure.Core.Expressions.DataFactory;
12+
13+
namespace Azure.ResourceManager.DataFactory.Models
14+
{
15+
/// <summary> Avro dataset. </summary>
16+
[CodeGenSuppress(nameof(AvroDataset), typeof(string), typeof(string), typeof(DataFactoryElement<IList<DatasetDataElement>>),
17+
typeof(DataFactoryElement<BinaryData>), typeof(Core.Expressions.DataFactory.DataFactoryLinkedServiceReference), typeof(IDictionary<string, EntityParameterSpecification>),
18+
typeof(IList<BinaryData>), typeof(string), typeof(IDictionary<string, BinaryData>), typeof(DatasetLocation), typeof(DataFactoryElement<string>), typeof(int))]
19+
public partial class AvroDataset : DataFactoryDatasetProperties
20+
{
21+
/// <summary> Initializes a new instance of <see cref="AvroDataset"/>. </summary>
22+
/// <param name="datasetType"> Type of dataset. </param>
23+
/// <param name="description"> Dataset description. </param>
24+
/// <param name="structure"> Columns that define the structure of the dataset. Type: array (or Expression with resultType array), itemType: DatasetDataElement. </param>
25+
/// <param name="schema"> Columns that define the physical type schema of the dataset. Type: array (or Expression with resultType array), itemType: DatasetSchemaDataElement. </param>
26+
/// <param name="linkedServiceName"> Linked service reference. </param>
27+
/// <param name="parameters"> Parameters for dataset. </param>
28+
/// <param name="annotations"> List of tags that can be used for describing the Dataset. </param>
29+
/// <param name="folder"> The folder that this Dataset is in. If not specified, Dataset will appear at the root level. </param>
30+
/// <param name="additionalProperties"> Additional Properties. </param>
31+
/// <param name="dataLocation">
32+
/// The location of the avro storage.
33+
/// Please note <see cref="DatasetLocation"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
34+
/// The available derived classes include <see cref="AmazonS3CompatibleLocation"/>, <see cref="AmazonS3Location"/>, <see cref="AzureBlobFSLocation"/>, <see cref="AzureBlobStorageLocation"/>, <see cref="AzureDataLakeStoreLocation"/>, <see cref="AzureFileStorageLocation"/>, <see cref="FileServerLocation"/>, <see cref="FtpServerLocation"/>, <see cref="GoogleCloudStorageLocation"/>, <see cref="HdfsLocation"/>, <see cref="HttpServerLocation"/>, <see cref="LakeHouseLocation"/>, <see cref="OracleCloudStorageLocation"/> and <see cref="SftpLocation"/>.
35+
/// </param>
36+
/// <param name="avroCompressionCodec"> The data avroCompressionCodec. Type: string (or Expression with resultType string). </param>
37+
/// <param name="avroCompressionLevel"></param>
38+
internal AvroDataset(string datasetType, string description, DataFactoryElement<IList<DatasetDataElement>> structure, DataFactoryElement<BinaryData> schema, Core.Expressions.DataFactory.DataFactoryLinkedServiceReference linkedServiceName, IDictionary<string, EntityParameterSpecification> parameters, IList<BinaryData> annotations, DatasetFolder folder, IDictionary<string, BinaryData> additionalProperties, DatasetLocation dataLocation, DataFactoryElement<string> avroCompressionCodec, int? avroCompressionLevel) : base(datasetType, description, structure, null, linkedServiceName, parameters, annotations, folder, additionalProperties)
39+
{
40+
DataLocation = dataLocation;
41+
AvroCompressionCodec = avroCompressionCodec;
42+
AvroCompressionLevel = avroCompressionLevel;
43+
DatasetType = datasetType ?? "Avro";
44+
Schema = schema;
45+
}
46+
47+
/// <summary> Columns that define the physical type schema of the dataset. Type: array (or Expression with resultType array), itemType: DatasetSchemaDataElement. </summary>
48+
public new DataFactoryElement<BinaryData> Schema { get; set; }
49+
50+
internal static AvroDataset DeserializeAvroDataset(JsonElement element)
51+
{
52+
if (element.ValueKind == JsonValueKind.Null)
53+
{
54+
return null;
55+
}
56+
string type = default;
57+
Optional<string> description = default;
58+
Optional<DataFactoryElement<IList<DatasetDataElement>>> structure = default;
59+
Optional<DataFactoryElement<BinaryData>> schema = default;
60+
Core.Expressions.DataFactory.DataFactoryLinkedServiceReference linkedServiceName = default;
61+
Optional<IDictionary<string, EntityParameterSpecification>> parameters = default;
62+
Optional<IList<BinaryData>> annotations = default;
63+
Optional<DatasetFolder> folder = default;
64+
Optional<DatasetLocation> location = default;
65+
Optional<DataFactoryElement<string>> avroCompressionCodec = default;
66+
Optional<int> avroCompressionLevel = default;
67+
IDictionary<string, BinaryData> additionalProperties = default;
68+
Dictionary<string, BinaryData> additionalPropertiesDictionary = new Dictionary<string, BinaryData>();
69+
foreach (var property in element.EnumerateObject())
70+
{
71+
if (property.NameEquals("type"u8))
72+
{
73+
type = property.Value.GetString();
74+
continue;
75+
}
76+
if (property.NameEquals("description"u8))
77+
{
78+
description = property.Value.GetString();
79+
continue;
80+
}
81+
if (property.NameEquals("structure"u8))
82+
{
83+
if (property.Value.ValueKind == JsonValueKind.Null)
84+
{
85+
continue;
86+
}
87+
structure = JsonSerializer.Deserialize<DataFactoryElement<IList<DatasetDataElement>>>(property.Value.GetRawText());
88+
continue;
89+
}
90+
if (property.NameEquals("schema"u8))
91+
{
92+
if (property.Value.ValueKind == JsonValueKind.Null)
93+
{
94+
continue;
95+
}
96+
schema = JsonSerializer.Deserialize<DataFactoryElement<BinaryData>>(property.Value.GetRawText());
97+
continue;
98+
}
99+
if (property.NameEquals("linkedServiceName"u8))
100+
{
101+
linkedServiceName = JsonSerializer.Deserialize<Core.Expressions.DataFactory.DataFactoryLinkedServiceReference>(property.Value.GetRawText());
102+
continue;
103+
}
104+
if (property.NameEquals("parameters"u8))
105+
{
106+
if (property.Value.ValueKind == JsonValueKind.Null)
107+
{
108+
continue;
109+
}
110+
Dictionary<string, EntityParameterSpecification> dictionary = new Dictionary<string, EntityParameterSpecification>();
111+
foreach (var property0 in property.Value.EnumerateObject())
112+
{
113+
dictionary.Add(property0.Name, EntityParameterSpecification.DeserializeEntityParameterSpecification(property0.Value));
114+
}
115+
parameters = dictionary;
116+
continue;
117+
}
118+
if (property.NameEquals("annotations"u8))
119+
{
120+
if (property.Value.ValueKind == JsonValueKind.Null)
121+
{
122+
continue;
123+
}
124+
List<BinaryData> array = new List<BinaryData>();
125+
foreach (var item in property.Value.EnumerateArray())
126+
{
127+
if (item.ValueKind == JsonValueKind.Null)
128+
{
129+
array.Add(null);
130+
}
131+
else
132+
{
133+
array.Add(BinaryData.FromString(item.GetRawText()));
134+
}
135+
}
136+
annotations = array;
137+
continue;
138+
}
139+
if (property.NameEquals("folder"u8))
140+
{
141+
if (property.Value.ValueKind == JsonValueKind.Null)
142+
{
143+
continue;
144+
}
145+
folder = DatasetFolder.DeserializeDatasetFolder(property.Value);
146+
continue;
147+
}
148+
if (property.NameEquals("typeProperties"u8))
149+
{
150+
if (property.Value.ValueKind == JsonValueKind.Null)
151+
{
152+
property.ThrowNonNullablePropertyIsNull();
153+
continue;
154+
}
155+
foreach (var property0 in property.Value.EnumerateObject())
156+
{
157+
if (property0.NameEquals("location"u8))
158+
{
159+
if (property0.Value.ValueKind == JsonValueKind.Null)
160+
{
161+
continue;
162+
}
163+
location = DatasetLocation.DeserializeDatasetLocation(property0.Value);
164+
continue;
165+
}
166+
if (property0.NameEquals("avroCompressionCodec"u8))
167+
{
168+
if (property0.Value.ValueKind == JsonValueKind.Null)
169+
{
170+
continue;
171+
}
172+
avroCompressionCodec = JsonSerializer.Deserialize<DataFactoryElement<string>>(property0.Value.GetRawText());
173+
continue;
174+
}
175+
if (property0.NameEquals("avroCompressionLevel"u8))
176+
{
177+
if (property0.Value.ValueKind == JsonValueKind.Null)
178+
{
179+
continue;
180+
}
181+
avroCompressionLevel = property0.Value.GetInt32();
182+
continue;
183+
}
184+
}
185+
continue;
186+
}
187+
additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
188+
}
189+
additionalProperties = additionalPropertiesDictionary;
190+
return new AvroDataset(type, description.Value, structure.Value, schema.Value, linkedServiceName, Optional.ToDictionary(parameters), Optional.ToList(annotations), folder.Value, additionalProperties, location.Value, avroCompressionCodec.Value, Optional.ToNullable(avroCompressionLevel));
191+
}
192+
}
193+
}

0 commit comments

Comments
 (0)