From 06a85375da4d1497bc734e1f4a6657c035d9392b Mon Sep 17 00:00:00 2001 From: NguyenHoangSon96 Date: Mon, 9 Dec 2024 14:43:50 +0700 Subject: [PATCH] fix: lint --- Client.Test/Internal/TypeCastTest.cs | 6 +++--- Client/InfluxDBClient.cs | 12 +----------- Client/Internal/TypeCasting.cs | 5 ++++- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Client.Test/Internal/TypeCastTest.cs b/Client.Test/Internal/TypeCastTest.cs index 85f39e0..bae677a 100644 --- a/Client.Test/Internal/TypeCastTest.cs +++ b/Client.Test/Internal/TypeCastTest.cs @@ -70,16 +70,16 @@ public void GetMappedValue() }); - field = GenerateIntFieldNullTypeMeta(fieldName); + field = GenerateIntFieldTestTypeMeta(fieldName); Assert.That(TypeCasting.GetMappedValue(field, 1)!, Is.EqualTo(1)); } - private static Field GenerateIntFieldNullTypeMeta(string fieldName) + private static Field GenerateIntFieldTestTypeMeta(string fieldName) { var meta = new Dictionary { { - "iox::column::type", null + "iox::column::type", "iox::column_type::field::test" } }; return new Field(fieldName, Int64Type.Default, true, meta); diff --git a/Client/InfluxDBClient.cs b/Client/InfluxDBClient.cs index 4062946..5e19f81 100644 --- a/Client/InfluxDBClient.cs +++ b/Client/InfluxDBClient.cs @@ -466,16 +466,9 @@ public InfluxDBClient() : this( for (var j = 0; j < columnCount; j++) { if (batch.Column(j) is not ArrowArray array) continue; - var value = array.GetObjectValue(i); - if (value is null) - { - row[j] = null; - continue; - } - row[j] = TypeCasting.GetMappedValue( batch.Schema.FieldsList[j], - value + array.GetObjectValue(i) ); } @@ -546,9 +539,6 @@ public async IAsyncEnumerable QueryPoints(string query, QueryTy continue; var objectValue = array.GetObjectValue(i); - if (objectValue is null) - continue; - if (fullName is "measurement" or "iox::measurement" && objectValue is string value) { diff --git a/Client/Internal/TypeCasting.cs b/Client/Internal/TypeCasting.cs index c294c49..7d529a8 100644 --- a/Client/Internal/TypeCasting.cs +++ b/Client/Internal/TypeCasting.cs @@ -13,8 +13,11 @@ public class TypeCasting /// The Field object from Arrow /// The value to cast /// The value with the correct type - public static object GetMappedValue(Field field, object value) + public static object? GetMappedValue(Field field, object? value) { + if (value == null) + return null; + var fieldName = field.Name; if (fieldName is "measurement" or "iox::measurement") {