CurtHagenlocher commented on code in PR #2048:
URL: https://github.com/apache/arrow-adbc/pull/2048#discussion_r1704550381
##########
csharp/src/Apache.Arrow.Adbc/Extensions/StandardSchemaExtensions.cs:
##########
@@ -87,6 +107,7 @@ private class ContainerArray : Array
{
public ContainerArray(ArrayData data) : base(data)
{
+
Review Comment:
nit: remove blank line
##########
csharp/src/Apache.Arrow.Adbc/Extensions/StandardSchemaExtensions.cs:
##########
@@ -65,9 +65,29 @@ public static IReadOnlyList<IArrowArray> Validate(this
IReadOnlyList<Field> sche
else if (field.DataType.TypeId == ArrowTypeId.List)
{
ListType listType = (ListType)field.DataType;
+
if (listType.Fields.Count > 0)
{
- Validate(listType.Fields, dataField.Children.Select(e
=> new ContainerArray(e)).ToList());
+ List<Field> fieldsToValidate = new List<Field>();
+ List<ContainerArray> arrayDataToValidate = new
List<ContainerArray>();
+
+ for (int j=0;j<listType.Fields.Count;j++)
Review Comment:
Valid list types have just one field, so this loop shouldn't be needed. You
can access the item' field via ListType.ValueField.
##########
csharp/src/Drivers/BigQuery/BigQueryStatement.cs:
##########
@@ -273,7 +273,10 @@ private string SerializeToJson(StructArray structArray,
int index)
}
else
{
- jsonDictionary.Add(name,
ParseStructArray(structArray1, index));
+ if (index < structArray1.Length)
Review Comment:
The logic in this method might be easier to follow with a few strategic
comments distinguishing between the various branches it's possible to take.
##########
csharp/test/Drivers/BigQuery/BigQueryData.cs:
##########
@@ -125,82 +126,82 @@ public static SampleDataBuilder GetSampleData()
"STRUCT(CAST(NULL as STRING) as name, CAST(NULL as
INT64) as age) as person",
ExpectedValues = new List<ColumnNetTypeArrowTypeValue>()
{
- new ColumnNetTypeArrowTypeValue("id", typeof(long),
typeof(Int64Type), null),
- new ColumnNetTypeArrowTypeValue("number",
typeof(double), typeof(DoubleType), null),
- new ColumnNetTypeArrowTypeValue("decimal",
typeof(SqlDecimal), typeof(Decimal128Type), null),
- new ColumnNetTypeArrowTypeValue("big_decimal",
typeof(string), typeof(StringType), null),
- new ColumnNetTypeArrowTypeValue("is_active",
typeof(bool), typeof(BooleanType), null),
- new ColumnNetTypeArrowTypeValue("name",
typeof(string), typeof(StringType), null),
- new ColumnNetTypeArrowTypeValue("data",
typeof(byte[]), typeof(BinaryType), null),
- new ColumnNetTypeArrowTypeValue("date",
typeof(DateTime), typeof(Date64Type), null),
-#if NET6_0_OR_GREATER
- new ColumnNetTypeArrowTypeValue("time",
typeof(TimeOnly), typeof(Time64Type), null),
-#else
- new ColumnNetTypeArrowTypeValue("time",
typeof(TimeSpan), typeof(Time64Type), null),
-#endif
- new ColumnNetTypeArrowTypeValue("datetime",
typeof(DateTimeOffset), typeof(TimestampType), null),
- new ColumnNetTypeArrowTypeValue("timestamp",
typeof(DateTimeOffset), typeof(TimestampType), null),
- new ColumnNetTypeArrowTypeValue("point",
typeof(string), typeof(StringType), null),
- new ColumnNetTypeArrowTypeValue("numbers",
typeof(Int64Array), typeof(ListType), emptyNumbersArray),
- new ColumnNetTypeArrowTypeValue("person",
typeof(string), typeof(StringType), "{\"name\":null,\"age\":null}")
+ new ColumnNetTypeArrowTypeValue("id",
typeof(long), typeof(Int64Type), null),
+ new ColumnNetTypeArrowTypeValue("number",
typeof(double), typeof(DoubleType), null),
+ new ColumnNetTypeArrowTypeValue("decimal",
typeof(SqlDecimal), typeof(Decimal128Type), null),
+ new
ColumnNetTypeArrowTypeValue("big_decimal", typeof(string), typeof(StringType),
null),
+ new
ColumnNetTypeArrowTypeValue("is_active", typeof(bool), typeof(BooleanType),
null),
+ new ColumnNetTypeArrowTypeValue("name",
typeof(string), typeof(StringType), null),
+ new ColumnNetTypeArrowTypeValue("data",
typeof(byte[]), typeof(BinaryType), null),
+ new ColumnNetTypeArrowTypeValue("date",
typeof(DateTime), typeof(Date64Type), null),
+ #if NET6_0_OR_GREATER
+ new ColumnNetTypeArrowTypeValue("time",
typeof(TimeOnly), typeof(Time64Type), null),
+ #else
+ new ColumnNetTypeArrowTypeValue("time",
typeof(TimeSpan), typeof(Time64Type), null),
+ #endif
+ new
ColumnNetTypeArrowTypeValue("datetime", typeof(DateTimeOffset),
typeof(TimestampType), null),
+ new
ColumnNetTypeArrowTypeValue("timestamp", typeof(DateTimeOffset),
typeof(TimestampType), null),
+ new ColumnNetTypeArrowTypeValue("point",
typeof(string), typeof(StringType), null),
+ new ColumnNetTypeArrowTypeValue("numbers",
typeof(Int64Array), typeof(ListType), emptyNumbersArray),
+ new ColumnNetTypeArrowTypeValue("person",
typeof(string), typeof(StringType), "{\"name\":null,\"age\":null}")
}
});
// complex struct
sampleDataBuilder.Samples.Add(
- new SampleData()
- {
- Query = "SELECT " +
- "STRUCT(" +
- "\"Iron Man\" as name," +
- "\"Avengers\" as team," +
- "[\"Genius\", \"Billionaire\", \"Playboy\",
\"Philanthropist\"] as powers," +
- "[" +
- " STRUCT(" +
- " \"Captain America\" as name, " +
- " \"Avengers\" as team, " +
- " [\"Super Soldier Serum\", \"Vibranium
Shield\"] as powers, " +
- " [" +
- " STRUCT(" +
- " \"Thanos\" as name, " +
- " \"Black Order\" as team, " +
- " [\"Infinity Gauntlet\", \"Super
Strength\", \"Teleportation\"] as powers, " +
- " [" +
- " STRUCT(" +
- " \"Loki\" as name, " +
- " \"Asgard\" as team, " +
- " [\"Magic\", \"Shapeshifting\",
\"Trickery\"] as powers " +
- " )" +
- " ] as allies" +
- " )" +
- " ] as enemies" +
- " )," +
- " STRUCT(" +
- " \"Spider-Man\" as name, " +
- " \"Avengers\" as team, " +
- " [\"Spider-Sense\", \"Web-Shooting\",
\"Wall-Crawling\"] as powers, " +
- " [" +
- " STRUCT(" +
- " \"Green Goblin\" as name, " +
- " \"Sinister Six\" as team, " +
- " [\"Glider\", \"Pumpkin Bombs\", \"Super
Strength\"] as powers, " +
- " [" +
- " STRUCT(" +
- " \"Doctor Octopus\" as name, " +
- " \"Sinister Six\" as team, " +
- " [\"Mechanical Arms\", \"Genius\",
\"Madness\"] as powers " +
- " )" +
- " ] as allies" +
- " )" +
- " ] as enemies" +
- " )" +
- " ] as friends" +
- ") as iron_man",
- ExpectedValues = new List<ColumnNetTypeArrowTypeValue>()
+ new SampleData()
+ {
+ Query = "SELECT " +
+ "STRUCT(" +
+ "\"Iron Man\" as name," +
+ "\"Avengers\" as team," +
+ "[\"Genius\", \"Billionaire\", \"Playboy\",
\"Philanthropist\"] as powers," +
+ "[" +
+ " STRUCT(" +
+ " \"Captain America\" as name, " +
+ " \"Avengers\" as team, " +
+ " [\"Super Soldier Serum\", \"Vibranium Shield\"]
as powers, " +
+ " [" +
+ " STRUCT(" +
+ " \"Thanos\" as name, " +
+ " \"Black Order\" as team, " +
+ " [\"Infinity Gauntlet\", \"Super Strength\",
\"Teleportation\"] as powers, " +
+ " [" +
+ " STRUCT(" +
+ " \"Loki\" as name, " +
+ " \"Asgard\" as team, " +
+ " [\"Magic\", \"Shapeshifting\",
\"Trickery\"] as powers " +
+ " )" +
+ " ] as allies" +
+ " )" +
+ " ] as enemies" +
+ " )," +
+ " STRUCT(" +
+ " \"Spider-Man\" as name, " +
+ " \"Avengers\" as team, " +
+ " [\"Spider-Sense\", \"Web-Shooting\",
\"Wall-Crawling\"] as powers, " +
+ " [" +
+ " STRUCT(" +
+ " \"Green Goblin\" as name, " +
+ " \"Sinister Six\" as team, " +
+ " [\"Glider\", \"Pumpkin Bombs\", \"Super
Strength\"] as powers, " +
+ " [" +
+ " STRUCT(" +
+ " \"Doctor Octopus\" as name, " +
+ " \"Sinister Six\" as team, " +
+ " [\"Mechanical Arms\", \"Genius\",
\"Madness\"] as powers " +
+ " )" +
+ " ] as allies" +
+ " )" +
+ " ] as enemies" +
+ " )" +
+ " ] as friends" +
+ ") as iron_man",
+ ExpectedValues = new List<ColumnNetTypeArrowTypeValue>()
{
- new ColumnNetTypeArrowTypeValue("iron_man",
typeof(string), typeof(StringType), "{\"name\":\"Iron
Man\",\"team\":\"Avengers\",\"powers\":[\"Genius\",\"Billionaire\",\"Playboy\",\"Philanthropist\"],\"friends\":[{\"name\":\"Captain
America\",\"team\":\"Avengers\",\"powers\":[\"Super Soldier
Serum\",\"Vibranium Shield\"],\"enemies\":{\"name\":\"Thanos\",\"team\":\"Black
Order\",\"powers\":[\"Infinity Gauntlet\",\"Super
Strength\",\"Teleportation\"],\"allies\":{\"name\":\"Loki\",\"team\":\"Asgard\",\"powers\":[\"Magic\",\"Shapeshifting\",\"Trickery\"]}}},{\"name\":\"Spider-Man\",\"team\":\"Avengers\",\"powers\":[\"Spider-Sense\",\"Web-Shooting\",\"Wall-Crawling\"],\"enemies\":{\"name\":\"Green
Goblin\",\"team\":\"Sinister Six\",\"powers\":[\"Glider\",\"Pumpkin
Bombs\",\"Super Strength\"],\"allies\":{\"name\":\"Doctor
Octopus\",\"team\":\"Sinister Six\",\"powers\":[\"Mechanical
Arms\",\"Genius\",\"Madness\"]}}}]}")
+ new ColumnNetTypeArrowTypeValue("iron_man",
typeof(string), typeof(StringType), "{\"name\":\"Iron
Man\",\"team\":\"Avengers\",\"powers\":[\"Genius\",\"Billionaire\",\"Playboy\",\"Philanthropist\"],\"friends\":[{\"name\":\"Captain
America\",\"team\":\"Avengers\",\"powers\":[\"Super Soldier
Serum\",\"Vibranium Shield\"],\"enemies\":{\"name\":\"Thanos\",\"team\":\"Black
Order\",\"powers\":[\"Infinity Gauntlet\",\"Super
Strength\",\"Teleportation\"],\"allies\":{\"name\":\"Loki\",\"team\":\"Asgard\",\"powers\":[\"Magic\",\"Shapeshifting\",\"Trickery\"]}}},{\"name\":\"Spider-Man\",\"team\":\"Avengers\",\"powers\":[\"Spider-Sense\",\"Web-Shooting\",\"Wall-Crawling\"],\"enemies\":null}]}")
Review Comment:
I think it's great not to have enemies, but where did they go?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]