You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "xiangfu0 (via GitHub)" <gi...@apache.org> on 2026/07/24 05:11:44 UTC

[PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

xiangfu0 opened a new pull request, #19073:
URL: https://github.com/apache/pinot/pull/19073

   ## What
   
   Resolves #19071.
   
   `AvroUtils.getAvroSchemaFromPinotSchema` and `SegmentProcessorAvroUtils.convertPinotSchemaToAvroSchema` switched on `fieldSpec.getDataType().getStoredType()`, so the generated Avro schema described Pinot's **physical storage** rather than its **logical type**:
   
   - `BOOLEAN` was emitted as Avro `int`
   - `TIMESTAMP` was emitted as a bare `long` (no logical type)
   - `UUID` needed a one-off special case
   - `BIG_DECIMAL` fell through as unsupported
   
   ## Change
   
   Drive schema generation on the original (logical) `DataType` via a single shared mapping, `AvroSchemaUtil.toAvroSchema(DataType/FieldSpec)`:
   
   | Pinot type | Avro type | Writer value |
   |---|---|---|
   | BOOLEAN | `boolean` | `Boolean` (coerced from stored `int` 0/1) |
   | TIMESTAMP | `long{logicalType:timestamp-millis}` | `Long` epoch millis |
   | BIG_DECIMAL | `bytes{logicalType:big-decimal}` | `BigDecimal` via `BigDecimalConversion` |
   | UUID | `string{logicalType:uuid}` | 16-byte `byte[]` via `UuidConversion` |
   
   INT/LONG/FLOAT/DOUBLE/STRING/JSON/BYTES are unchanged. `AvroUtils.getAvroSchemaFromPinotSchema` and the `AvroSchemaUtil.toAvroSchemaJsonObject` JSON view now delegate to this one mapping, dropping the previous one-off UUID branches.
   
   Coordinate the writer/value side to match:
   
   - Register Avro's `BigDecimalConversion` alongside the existing `UuidConversion` on the shared data model (`SegmentProcessorAvroUtils.getAvroDataModel`).
   - Make `convertGenericRowToAvroRecord` schema-driven: coerce Pinot's stored `int` 0/1 to `Boolean` for BOOLEAN fields and wrap `byte[]` as `ByteBuffer` for BYTES, while leaving values a registered `Conversion` owns (UUID `byte[]`, `BigDecimal`) untouched. MV values keep a zero-copy view unless their element type actually needs a transform.
   
   `SegmentProcessorAvroUtils.convertPinotSchemaToAvroSchema` keeps a private copy of the mapping because `pinot-core` cannot depend on the `pinot-avro-base` plugin (and vice-versa); a cross-module test pins the two together so they can't drift.
   
   ## Compatibility
   
   - Reverse mapping (`AvroSchemaUtil.valueOf(Schema)`) is deliberately left one-way, preserving existing Pinot schema **inference** from Avro data.
   - None of these schemas flow to ZK, segment metadata, or inter-node wire protocols — the affected Avro/Parquet outputs are transient intra-process buffers or self-describing export files, so there is no rolling-upgrade concern.
   - **Output-format note for downstream consumers:** the `segment -> Avro` / `segment -> Parquet` export tools now emit `boolean` (was `int`) for BOOLEAN and `timestamp-millis` (was a bare `long`) for TIMESTAMP. Both stay self-describing and decodable.
   - The controller recommender's `AvroWriter` is intentionally **not** touched: its data generator cannot produce `BIG_DECIMAL` values, so wiring the conversion there would be untested/unreachable. The anonymizer's separate `getAvroSchemaFromPinotSchema` is likewise out of scope — it has its own value-generation model and fails loudly rather than silently mis-mapping.
   
   ## Tests
   
   - Pinot-schema-to-Avro-schema assertions for every logical type, single-value and multi-value (`AvroSchemaUtilTest`, `AvroUtilsTest`, `SegmentProcessorAvroUtilsTest`).
   - Cross-module consistency test pinning `SegmentProcessorAvroUtils`'s mapping to `AvroUtils`'s.
   - End-to-end write/read round-trips through the shared data model and the production `AvroRecordReader`, exercising the same conversions as the segment-processing writers (`SegmentProcessorAvroUtilsTest`), plus a full segment-build round-trip (`FileBasedSegmentWriterTest`) and the Avro + Parquet converters incl. `AvroParquetWriter.withDataModel` (`PinotSegmentConverterTest`). BigDecimal scale preservation and MV `byte[]` element-wise equality are asserted.


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on PR #19073:
URL: https://github.com/apache/pinot/pull/19073#issuecomment-5098328015

   Documentation follow-up: https://github.com/pinot-contrib/pinot-docs/pull/946 documents the Avro logical types emitted by `ConvertPinotSegment` for Avro and Parquet output.


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #19073:
URL: https://github.com/apache/pinot/pull/19073#discussion_r3649704102


##########
pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java:
##########
@@ -51,43 +54,99 @@ public static GenericData.Record convertGenericRowToAvroRecord(GenericRow generi
     return convertGenericRowToAvroRecord(genericRow, reusableRecord, genericRow.getFieldToValueMap().keySet());
   }
 
-  /// Convert a GenericRow to an avro GenericRecord
+  /// Convert a GenericRow to an avro GenericRecord.
+  ///
+  /// Values arrive in Pinot's internal (stored) representation and are coordinated with the Avro field type produced
+  /// by `AvroSchemaUtil.toAvroSchema`: whatever a registered logical-type [Conversion] can handle is left untouched
+  /// for the writer, and only the two cases Avro cannot resolve on its own are fixed up here (see
+  /// [#convertValue(Schema, Object)]).
   public static GenericData.Record convertGenericRowToAvroRecord(GenericRow genericRow,
       GenericData.Record reusableRecord, Set<String> fields) {
     Schema avroSchema = reusableRecord.getSchema();
     for (String field : fields) {
       Object value = genericRow.getValue(field);
-      if (value instanceof Object[]) {
-        // Array elements are written as-is. For MV UUID (array<string{logicalType:uuid}>) the elements are the raw
-        // 16-byte values; the uuid Conversion registered on the writer's data model (getAvroDataModel) renders each
-        // element to its canonical string at write time.
-        reusableRecord.put(field, Arrays.asList((Object[]) value));
-      } else if (value instanceof byte[]) {
-        // A byte[] bound for a plain BYTES field must be wrapped as ByteBuffer (GenericDatumWriter requires it for the
-        // bytes type). A byte[] bound for a UUID field (string{logicalType:uuid}) is left raw so the uuid Conversion
-        // registered on the writer's data model (getAvroDataModel) renders it to a canonical string at write time.
-        Schema.Field avroField = avroSchema.getField(field);
-        if (avroField != null && avroField.schema().getType() == Schema.Type.BYTES) {
-          reusableRecord.put(field, ByteBuffer.wrap((byte[]) value));
-        } else {
-          reusableRecord.put(field, value);
-        }
-      } else {
+      Schema.Field avroField = avroSchema.getField(field);
+      if (avroField == null) {
+        // Let Avro raise its own "Not a valid schema field" error for a column missing from the Avro schema.
         reusableRecord.put(field, value);
+      } else {
+        reusableRecord.put(avroField.pos(), convertValue(avroField.schema(), value));
       }
     }
     return reusableRecord;
   }
 
-  /// Shared Avro data model with [UuidConversion] registered. Populated once at class initialization and never
-  /// mutated afterward (effectively immutable), so it is safe to share across writers.
+  /// Adapts a Pinot value to the representation the Avro writer expects for the given field schema, recursing into
+  /// array elements for multi-value columns.
+  @Nullable
+  private static Object convertValue(Schema fieldSchema, @Nullable Object value) {
+    if (value == null) {
+      return null;
+    }
+    if (value instanceof Object[]) {
+      Object[] values = (Object[]) value;
+      Schema elementSchema =
+          fieldSchema.getType() == Schema.Type.ARRAY ? fieldSchema.getElementType() : fieldSchema;
+      // Only BOOLEAN (stored int -> Boolean) and BYTES (byte[] -> ByteBuffer) element schemas can require a
+      // per-element transform. Every other MV element type is written as-is — INT/LONG/FLOAT/DOUBLE/STRING directly,
+      // and UUID (string element, raw byte[] rendered by the registered Conversion) — so hand the writer a zero-copy
+      // view over the existing array; allocating and copying a fresh list per row would be pure overhead on the
+      // segment-write hot path. (BIG_DECIMAL has a BYTES element schema and so takes the copy path below, but its
+      // BigDecimal values still pass through convertSingleValue unchanged for the registered Conversion.)
+      Schema.Type elementType = elementSchema.getType();
+      if (elementType != Schema.Type.BOOLEAN && elementType != Schema.Type.BYTES) {
+        return Arrays.asList(values);
+      }
+      List<Object> converted = new ArrayList<>(values.length);

Review Comment:
   `convertValue()` currently takes the per-element conversion path for *all* MV fields whose Avro element schema is `BYTES`. That’s required for plain BYTES (byte[] -> ByteBuffer), but it also forces an unnecessary list allocation + element loop for BIG_DECIMAL MV columns (`bytes{logicalType:big-decimal}`) even though BigDecimal values can be passed through zero-copy and handled by the registered `BigDecimalConversion`.
   
   Consider treating `bytes{logicalType:big-decimal}` as a zero-copy case (like UUID), and only allocating/converting per-element for plain `bytes` schemas.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 merged PR #19073:
URL: https://github.com/apache/pinot/pull/19073


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19073:
URL: https://github.com/apache/pinot/pull/19073#issuecomment-5066665485

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/19073?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `77.41935%` with `14 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 37.89%. Comparing base ([`dded09d`](https://app.codecov.io/gh/apache/pinot/commit/dded09d82a84ae5e637c3e7c42e0240aacb4e23b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`3bd7b2f`](https://app.codecov.io/gh/apache/pinot/commit/3bd7b2f69a51d1927cb84f3bb1fa7e8e91767c21?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/19073?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...che/pinot/core/util/SegmentProcessorAvroUtils.java](https://app.codecov.io/gh/apache/pinot/pull/19073?src=pr&el=tree&filepath=pinot-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fcore%2Futil%2FSegmentProcessorAvroUtils.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS91dGlsL1NlZ21lbnRQcm9jZXNzb3JBdnJvVXRpbHMuamF2YQ==) | 71.05% | [4 Missing and 7 partials :warning: ](https://app.codecov.io/gh/apache/pinot/pull/19073?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../pinot/plugin/inputformat/avro/AvroSchemaUtil.java](https://app.codecov.io/gh/apache/pinot/pull/19073?src=pr&el=tree&filepath=pinot-plugins%2Fpinot-input-format%2Fpinot-avro-base%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fplugin%2Finputformat%2Favro%2FAvroSchemaUtil.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcGx1Z2lucy9waW5vdC1pbnB1dC1mb3JtYXQvcGlub3QtYXZyby1iYXNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9wbHVnaW4vaW5wdXRmb3JtYXQvYXZyby9BdnJvU2NoZW1hVXRpbC5qYXZh) | 86.36% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/19073?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (dded09d) and HEAD (3bd7b2f). Click for more details.
   > 
   > <details><summary>HEAD has 16 uploads less than BASE</summary>
   >
   >| Flag | BASE (dded09d) | HEAD (3bd7b2f) |
   >|------|------|------|
   >|unittests1|1|0|
   >|unittests|2|1|
   >|java-25|5|1|
   >|temurin|5|1|
   >|integration|3|0|
   >|integration1|1|0|
   >|integration2|1|0|
   >|custom-integration1|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##             master   #19073       +/-   ##
   =============================================
   - Coverage     65.45%   37.89%   -27.57%     
   + Complexity     1421     1414        -7     
   =============================================
     Files          3425     3425               
     Lines        216303   216252       -51     
     Branches      34266    34261        -5     
   =============================================
   - Hits         141590    81951    -59639     
   - Misses        63317   126830    +63513     
   + Partials      11396     7471     -3925     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-25](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.89% <77.41%> (-27.57%)` | :arrow_down: |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.89% <77.41%> (-27.57%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.89% <77.41%> (-27.57%)` | :arrow_down: |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/19073/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.89% <77.41%> (+0.02%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/pinot/pull/19073?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #19073:
URL: https://github.com/apache/pinot/pull/19073#discussion_r3660279320


##########
pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java:
##########
@@ -133,74 +193,57 @@ public byte[] fromCharSequence(CharSequence value, Schema schema, LogicalType ty
     }
   }
 
-  /// Converts a Pinot schema to an Avro schema
+  /// Converts a Pinot schema to an Avro schema, with the fields ordered by column name.
+  ///
+  /// Field types are derived from the **original (logical)** Pinot data type, so BOOLEAN becomes Avro `boolean`,
+  /// TIMESTAMP a `timestamp-millis` long, BIG_DECIMAL a `big-decimal` bytes and UUID a `uuid` string, instead of all
+  /// four collapsing to their physical storage type. This must stay identical to
+  /// `AvroSchemaUtil.toAvroSchema(FieldSpec)` in `pinot-avro-base` — the two live in different modules (neither can
+  /// depend on the other) but feed the same writers, so `SegmentProcessorAvroUtilsTest` pins them together. See that
+  /// method for the full mapping table and the value representation each Avro type expects.
   public static Schema convertPinotSchemaToAvroSchema(org.apache.pinot.spi.data.Schema pinotSchema) {
     SchemaBuilder.FieldAssembler<org.apache.avro.Schema> fieldAssembler = SchemaBuilder.record("record").fields();
-
     List<FieldSpec> orderedFieldSpecs = pinotSchema.getAllFieldSpecs().stream()
         .sorted(Comparator.comparing(FieldSpec::getName))
         .collect(Collectors.toList());
     for (FieldSpec fieldSpec : orderedFieldSpecs) {
-      String name = fieldSpec.getName();
-      // Emit UUID columns as Avro string{logicalType:uuid} (matching AvroUtils.getAvroSchemaFromPinotSchema)
-      // so the runtime byte[] → canonical-string conversion in convertGenericRowToAvroRecord lines up with
-      // the field schema. Without this branch SV UUID would fall through to BYTES (losing UUID semantics) and
-      // MV UUID would throw at this point (MV switch below has no BYTES case).
-      if (fieldSpec.getDataType() == DataType.UUID) {
-        Schema uuidSchema = LogicalTypes.uuid().addToSchema(Schema.create(Schema.Type.STRING));
-        if (fieldSpec.isSingleValueField()) {
-          fieldAssembler = fieldAssembler.name(name).type(uuidSchema).noDefault();
-        } else {
-          fieldAssembler = fieldAssembler.name(name).type().array().items(uuidSchema).noDefault();
-        }
-        continue;
-      }
-      DataType storedType = fieldSpec.getDataType().getStoredType();
-      if (fieldSpec.isSingleValueField()) {
-        switch (storedType) {
-          case INT:
-            fieldAssembler = fieldAssembler.name(name).type().intType().noDefault();
-            break;
-          case LONG:
-            fieldAssembler = fieldAssembler.name(name).type().longType().noDefault();
-            break;
-          case FLOAT:
-            fieldAssembler = fieldAssembler.name(name).type().floatType().noDefault();
-            break;
-          case DOUBLE:
-            fieldAssembler = fieldAssembler.name(name).type().doubleType().noDefault();
-            break;
-          case STRING:
-            fieldAssembler = fieldAssembler.name(name).type().stringType().noDefault();
-            break;
-          case BYTES:
-            fieldAssembler = fieldAssembler.name(name).type().bytesType().noDefault();
-            break;
-          default:
-            throw new RuntimeException("Unsupported data type: " + storedType);
-        }
-      } else {
-        switch (storedType) {
-          case INT:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().intType().noDefault();
-            break;
-          case LONG:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().longType().noDefault();
-            break;
-          case FLOAT:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().floatType().noDefault();
-            break;
-          case DOUBLE:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().doubleType().noDefault();
-            break;
-          case STRING:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().stringType().noDefault();
-            break;
-          default:
-            throw new RuntimeException("Unsupported data type: " + storedType);
-        }
-      }
+      fieldAssembler = fieldAssembler.name(fieldSpec.getName()).type(toAvroSchema(fieldSpec)).noDefault();
     }
     return fieldAssembler.endRecord();
   }
+
+  /// Returns the Avro schema for a whole Pinot column: the single-value type from [#toAvroSchema(DataType)], or an
+  /// array of it for a multi-value column.
+  private static Schema toAvroSchema(FieldSpec fieldSpec) {
+    Schema valueSchema = toAvroSchema(fieldSpec.getDataType());
+    return fieldSpec.isSingleValueField() ? valueSchema : Schema.createArray(valueSchema);
+  }
+
+  private static Schema toAvroSchema(DataType dataType) {
+    switch (dataType) {
+      case INT:
+        return Schema.create(Schema.Type.INT);
+      case LONG:
+        return Schema.create(Schema.Type.LONG);
+      case FLOAT:
+        return Schema.create(Schema.Type.FLOAT);
+      case DOUBLE:
+        return Schema.create(Schema.Type.DOUBLE);
+      case BOOLEAN:
+        return Schema.create(Schema.Type.BOOLEAN);
+      case TIMESTAMP:
+        return LogicalTypes.timestampMillis().addToSchema(Schema.create(Schema.Type.LONG));
+      case BIG_DECIMAL:
+        return LogicalTypes.bigDecimal().addToSchema(Schema.create(Schema.Type.BYTES));
+      case STRING:
+      case JSON:
+        return Schema.create(Schema.Type.STRING);
+      case BYTES:
+        return Schema.create(Schema.Type.BYTES);
+      case UUID:
+        return LogicalTypes.uuid().addToSchema(Schema.create(Schema.Type.STRING));

Review Comment:
   Do we want to use `BYTES` for `UUID`?



##########
pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java:
##########
@@ -51,43 +54,99 @@ public static GenericData.Record convertGenericRowToAvroRecord(GenericRow generi
     return convertGenericRowToAvroRecord(genericRow, reusableRecord, genericRow.getFieldToValueMap().keySet());
   }
 
-  /// Convert a GenericRow to an avro GenericRecord
+  /// Convert a GenericRow to an avro GenericRecord.
+  ///
+  /// Values arrive in Pinot's internal (stored) representation and are coordinated with the Avro field type produced
+  /// by `AvroSchemaUtil.toAvroSchema`: whatever a registered logical-type [Conversion] can handle is left untouched
+  /// for the writer, and only the two cases Avro cannot resolve on its own are fixed up here (see
+  /// [#convertValue(Schema, Object)]).
   public static GenericData.Record convertGenericRowToAvroRecord(GenericRow genericRow,
       GenericData.Record reusableRecord, Set<String> fields) {
     Schema avroSchema = reusableRecord.getSchema();
     for (String field : fields) {
       Object value = genericRow.getValue(field);
-      if (value instanceof Object[]) {
-        // Array elements are written as-is. For MV UUID (array<string{logicalType:uuid}>) the elements are the raw
-        // 16-byte values; the uuid Conversion registered on the writer's data model (getAvroDataModel) renders each
-        // element to its canonical string at write time.
-        reusableRecord.put(field, Arrays.asList((Object[]) value));
-      } else if (value instanceof byte[]) {
-        // A byte[] bound for a plain BYTES field must be wrapped as ByteBuffer (GenericDatumWriter requires it for the
-        // bytes type). A byte[] bound for a UUID field (string{logicalType:uuid}) is left raw so the uuid Conversion
-        // registered on the writer's data model (getAvroDataModel) renders it to a canonical string at write time.
-        Schema.Field avroField = avroSchema.getField(field);
-        if (avroField != null && avroField.schema().getType() == Schema.Type.BYTES) {
-          reusableRecord.put(field, ByteBuffer.wrap((byte[]) value));
-        } else {
-          reusableRecord.put(field, value);
-        }
-      } else {
+      Schema.Field avroField = avroSchema.getField(field);
+      if (avroField == null) {
+        // Let Avro raise its own "Not a valid schema field" error for a column missing from the Avro schema.
         reusableRecord.put(field, value);
+      } else {
+        reusableRecord.put(avroField.pos(), convertValue(avroField.schema(), value));
       }
     }
     return reusableRecord;
   }
 
-  /// Shared Avro data model with [UuidConversion] registered. Populated once at class initialization and never
-  /// mutated afterward (effectively immutable), so it is safe to share across writers.
+  /// Adapts a Pinot value to the representation the Avro writer expects for the given field schema, recursing into
+  /// array elements for multi-value columns.
+  @Nullable
+  private static Object convertValue(Schema fieldSchema, @Nullable Object value) {
+    if (value == null) {
+      return null;
+    }
+    if (value instanceof Object[]) {
+      Object[] values = (Object[]) value;
+      Schema elementSchema =
+          fieldSchema.getType() == Schema.Type.ARRAY ? fieldSchema.getElementType() : fieldSchema;
+      // Only BOOLEAN (stored int -> Boolean) and BYTES (byte[] -> ByteBuffer) element schemas can require a
+      // per-element transform. Every other MV element type is written as-is — INT/LONG/FLOAT/DOUBLE/STRING directly,
+      // and UUID (string element, raw byte[] rendered by the registered Conversion) — so hand the writer a zero-copy
+      // view over the existing array; allocating and copying a fresh list per row would be pure overhead on the
+      // segment-write hot path. (BIG_DECIMAL has a BYTES element schema and so takes the copy path below, but its
+      // BigDecimal values still pass through convertSingleValue unchanged for the registered Conversion.)
+      Schema.Type elementType = elementSchema.getType();
+      if (elementType != Schema.Type.BOOLEAN && elementType != Schema.Type.BYTES) {
+        return Arrays.asList(values);
+      }
+      List<Object> converted = new ArrayList<>(values.length);
+      for (Object singleValue : values) {
+        converted.add(convertSingleValue(elementSchema, singleValue));
+      }
+      return converted;
+    }
+    return convertSingleValue(fieldSchema, value);
+  }
+
+  /// Adapts a single (non-array) Pinot value to what `GenericDatumWriter` expects for `valueSchema`.
+  ///
+  /// Only two cases need fixing up; everything else is written as-is, either because the Pinot representation already
+  /// *is* the Avro representation (`Integer` for `int`, `Long` for `long{timestamp-millis}`, `String` for `string`)
+  /// or because a [Conversion] registered on [#getAvroDataModel] handles it (`byte[]` for `string{uuid}`,
+  /// [java.math.BigDecimal] for `bytes{big-decimal}`).
+  @Nullable
+  private static Object convertSingleValue(Schema valueSchema, @Nullable Object value) {
+    if (value == null) {
+      return null;
+    }
+    switch (valueSchema.getType()) {
+      case BOOLEAN:
+        // BOOLEAN is the one Pinot logical type with no Avro logical type to carry a Conversion, so its stored int
+        // 0/1 has to be coerced here. Values that are already Boolean (e.g. from a source that never went through
+        // Pinot's stored form) pass through.
+        return value instanceof Boolean ? value : ((Number) value).intValue() != 0;

Review Comment:
   Is the `value` always `Integer`? If so, we can simplify the check for better performance. Same for `BYTES`. Is the `value` always `byte[]`?



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on code in PR #19073:
URL: https://github.com/apache/pinot/pull/19073#discussion_r3661178385


##########
pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java:
##########
@@ -133,74 +193,57 @@ public byte[] fromCharSequence(CharSequence value, Schema schema, LogicalType ty
     }
   }
 
-  /// Converts a Pinot schema to an Avro schema
+  /// Converts a Pinot schema to an Avro schema, with the fields ordered by column name.
+  ///
+  /// Field types are derived from the **original (logical)** Pinot data type, so BOOLEAN becomes Avro `boolean`,
+  /// TIMESTAMP a `timestamp-millis` long, BIG_DECIMAL a `big-decimal` bytes and UUID a `uuid` string, instead of all
+  /// four collapsing to their physical storage type. This must stay identical to
+  /// `AvroSchemaUtil.toAvroSchema(FieldSpec)` in `pinot-avro-base` — the two live in different modules (neither can
+  /// depend on the other) but feed the same writers, so `SegmentProcessorAvroUtilsTest` pins them together. See that
+  /// method for the full mapping table and the value representation each Avro type expects.
   public static Schema convertPinotSchemaToAvroSchema(org.apache.pinot.spi.data.Schema pinotSchema) {
     SchemaBuilder.FieldAssembler<org.apache.avro.Schema> fieldAssembler = SchemaBuilder.record("record").fields();
-
     List<FieldSpec> orderedFieldSpecs = pinotSchema.getAllFieldSpecs().stream()
         .sorted(Comparator.comparing(FieldSpec::getName))
         .collect(Collectors.toList());
     for (FieldSpec fieldSpec : orderedFieldSpecs) {
-      String name = fieldSpec.getName();
-      // Emit UUID columns as Avro string{logicalType:uuid} (matching AvroUtils.getAvroSchemaFromPinotSchema)
-      // so the runtime byte[] → canonical-string conversion in convertGenericRowToAvroRecord lines up with
-      // the field schema. Without this branch SV UUID would fall through to BYTES (losing UUID semantics) and
-      // MV UUID would throw at this point (MV switch below has no BYTES case).
-      if (fieldSpec.getDataType() == DataType.UUID) {
-        Schema uuidSchema = LogicalTypes.uuid().addToSchema(Schema.create(Schema.Type.STRING));
-        if (fieldSpec.isSingleValueField()) {
-          fieldAssembler = fieldAssembler.name(name).type(uuidSchema).noDefault();
-        } else {
-          fieldAssembler = fieldAssembler.name(name).type().array().items(uuidSchema).noDefault();
-        }
-        continue;
-      }
-      DataType storedType = fieldSpec.getDataType().getStoredType();
-      if (fieldSpec.isSingleValueField()) {
-        switch (storedType) {
-          case INT:
-            fieldAssembler = fieldAssembler.name(name).type().intType().noDefault();
-            break;
-          case LONG:
-            fieldAssembler = fieldAssembler.name(name).type().longType().noDefault();
-            break;
-          case FLOAT:
-            fieldAssembler = fieldAssembler.name(name).type().floatType().noDefault();
-            break;
-          case DOUBLE:
-            fieldAssembler = fieldAssembler.name(name).type().doubleType().noDefault();
-            break;
-          case STRING:
-            fieldAssembler = fieldAssembler.name(name).type().stringType().noDefault();
-            break;
-          case BYTES:
-            fieldAssembler = fieldAssembler.name(name).type().bytesType().noDefault();
-            break;
-          default:
-            throw new RuntimeException("Unsupported data type: " + storedType);
-        }
-      } else {
-        switch (storedType) {
-          case INT:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().intType().noDefault();
-            break;
-          case LONG:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().longType().noDefault();
-            break;
-          case FLOAT:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().floatType().noDefault();
-            break;
-          case DOUBLE:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().doubleType().noDefault();
-            break;
-          case STRING:
-            fieldAssembler = fieldAssembler.name(name).type().array().items().stringType().noDefault();
-            break;
-          default:
-            throw new RuntimeException("Unsupported data type: " + storedType);
-        }
-      }
+      fieldAssembler = fieldAssembler.name(fieldSpec.getName()).type(toAvroSchema(fieldSpec)).noDefault();
     }
     return fieldAssembler.endRecord();
   }
+
+  /// Returns the Avro schema for a whole Pinot column: the single-value type from [#toAvroSchema(DataType)], or an
+  /// array of it for a multi-value column.
+  private static Schema toAvroSchema(FieldSpec fieldSpec) {
+    Schema valueSchema = toAvroSchema(fieldSpec.getDataType());
+    return fieldSpec.isSingleValueField() ? valueSchema : Schema.createArray(valueSchema);
+  }
+
+  private static Schema toAvroSchema(DataType dataType) {
+    switch (dataType) {
+      case INT:
+        return Schema.create(Schema.Type.INT);
+      case LONG:
+        return Schema.create(Schema.Type.LONG);
+      case FLOAT:
+        return Schema.create(Schema.Type.FLOAT);
+      case DOUBLE:
+        return Schema.create(Schema.Type.DOUBLE);
+      case BOOLEAN:
+        return Schema.create(Schema.Type.BOOLEAN);
+      case TIMESTAMP:
+        return LogicalTypes.timestampMillis().addToSchema(Schema.create(Schema.Type.LONG));
+      case BIG_DECIMAL:
+        return LogicalTypes.bigDecimal().addToSchema(Schema.create(Schema.Type.BYTES));
+      case STRING:
+      case JSON:
+        return Schema.create(Schema.Type.STRING);
+      case BYTES:
+        return Schema.create(Schema.Type.BYTES);
+      case UUID:
+        return LogicalTypes.uuid().addToSchema(Schema.create(Schema.Type.STRING));

Review Comment:
   Kept `string{logicalType:uuid}` intentionally. Plain Avro BYTES would lose UUID logical identity and change the output established by #18870; Avro UUID supports string or fixed(16), not BYTES. fixed(16) would require a broader named-schema, conversion, and compatibility change, so it is outside this PR.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Generate Avro schemas from Pinot logical data types (#19071) [pinot]

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on code in PR #19073:
URL: https://github.com/apache/pinot/pull/19073#discussion_r3661177218


##########
pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java:
##########
@@ -51,43 +54,99 @@ public static GenericData.Record convertGenericRowToAvroRecord(GenericRow generi
     return convertGenericRowToAvroRecord(genericRow, reusableRecord, genericRow.getFieldToValueMap().keySet());
   }
 
-  /// Convert a GenericRow to an avro GenericRecord
+  /// Convert a GenericRow to an avro GenericRecord.
+  ///
+  /// Values arrive in Pinot's internal (stored) representation and are coordinated with the Avro field type produced
+  /// by `AvroSchemaUtil.toAvroSchema`: whatever a registered logical-type [Conversion] can handle is left untouched
+  /// for the writer, and only the two cases Avro cannot resolve on its own are fixed up here (see
+  /// [#convertValue(Schema, Object)]).
   public static GenericData.Record convertGenericRowToAvroRecord(GenericRow genericRow,
       GenericData.Record reusableRecord, Set<String> fields) {
     Schema avroSchema = reusableRecord.getSchema();
     for (String field : fields) {
       Object value = genericRow.getValue(field);
-      if (value instanceof Object[]) {
-        // Array elements are written as-is. For MV UUID (array<string{logicalType:uuid}>) the elements are the raw
-        // 16-byte values; the uuid Conversion registered on the writer's data model (getAvroDataModel) renders each
-        // element to its canonical string at write time.
-        reusableRecord.put(field, Arrays.asList((Object[]) value));
-      } else if (value instanceof byte[]) {
-        // A byte[] bound for a plain BYTES field must be wrapped as ByteBuffer (GenericDatumWriter requires it for the
-        // bytes type). A byte[] bound for a UUID field (string{logicalType:uuid}) is left raw so the uuid Conversion
-        // registered on the writer's data model (getAvroDataModel) renders it to a canonical string at write time.
-        Schema.Field avroField = avroSchema.getField(field);
-        if (avroField != null && avroField.schema().getType() == Schema.Type.BYTES) {
-          reusableRecord.put(field, ByteBuffer.wrap((byte[]) value));
-        } else {
-          reusableRecord.put(field, value);
-        }
-      } else {
+      Schema.Field avroField = avroSchema.getField(field);
+      if (avroField == null) {
+        // Let Avro raise its own "Not a valid schema field" error for a column missing from the Avro schema.
         reusableRecord.put(field, value);
+      } else {
+        reusableRecord.put(avroField.pos(), convertValue(avroField.schema(), value));
       }
     }
     return reusableRecord;
   }
 
-  /// Shared Avro data model with [UuidConversion] registered. Populated once at class initialization and never
-  /// mutated afterward (effectively immutable), so it is safe to share across writers.
+  /// Adapts a Pinot value to the representation the Avro writer expects for the given field schema, recursing into
+  /// array elements for multi-value columns.
+  @Nullable
+  private static Object convertValue(Schema fieldSchema, @Nullable Object value) {
+    if (value == null) {
+      return null;
+    }
+    if (value instanceof Object[]) {
+      Object[] values = (Object[]) value;
+      Schema elementSchema =
+          fieldSchema.getType() == Schema.Type.ARRAY ? fieldSchema.getElementType() : fieldSchema;
+      // Only BOOLEAN (stored int -> Boolean) and BYTES (byte[] -> ByteBuffer) element schemas can require a
+      // per-element transform. Every other MV element type is written as-is — INT/LONG/FLOAT/DOUBLE/STRING directly,
+      // and UUID (string element, raw byte[] rendered by the registered Conversion) — so hand the writer a zero-copy
+      // view over the existing array; allocating and copying a fresh list per row would be pure overhead on the
+      // segment-write hot path. (BIG_DECIMAL has a BYTES element schema and so takes the copy path below, but its
+      // BigDecimal values still pass through convertSingleValue unchanged for the registered Conversion.)
+      Schema.Type elementType = elementSchema.getType();
+      if (elementType != Schema.Type.BOOLEAN && elementType != Schema.Type.BYTES) {
+        return Arrays.asList(values);
+      }
+      List<Object> converted = new ArrayList<>(values.length);

Review Comment:
   Addressed in dc7f174598: MV `bytes{logicalType:big-decimal}` now uses the zero-copy array-view path; only BOOLEAN and plain BYTES convert per element. I also added a regression test that mutates the backing array and verifies the record retains that view.



##########
pinot-core/src/main/java/org/apache/pinot/core/util/SegmentProcessorAvroUtils.java:
##########
@@ -51,43 +54,99 @@ public static GenericData.Record convertGenericRowToAvroRecord(GenericRow generi
     return convertGenericRowToAvroRecord(genericRow, reusableRecord, genericRow.getFieldToValueMap().keySet());
   }
 
-  /// Convert a GenericRow to an avro GenericRecord
+  /// Convert a GenericRow to an avro GenericRecord.
+  ///
+  /// Values arrive in Pinot's internal (stored) representation and are coordinated with the Avro field type produced
+  /// by `AvroSchemaUtil.toAvroSchema`: whatever a registered logical-type [Conversion] can handle is left untouched
+  /// for the writer, and only the two cases Avro cannot resolve on its own are fixed up here (see
+  /// [#convertValue(Schema, Object)]).
   public static GenericData.Record convertGenericRowToAvroRecord(GenericRow genericRow,
       GenericData.Record reusableRecord, Set<String> fields) {
     Schema avroSchema = reusableRecord.getSchema();
     for (String field : fields) {
       Object value = genericRow.getValue(field);
-      if (value instanceof Object[]) {
-        // Array elements are written as-is. For MV UUID (array<string{logicalType:uuid}>) the elements are the raw
-        // 16-byte values; the uuid Conversion registered on the writer's data model (getAvroDataModel) renders each
-        // element to its canonical string at write time.
-        reusableRecord.put(field, Arrays.asList((Object[]) value));
-      } else if (value instanceof byte[]) {
-        // A byte[] bound for a plain BYTES field must be wrapped as ByteBuffer (GenericDatumWriter requires it for the
-        // bytes type). A byte[] bound for a UUID field (string{logicalType:uuid}) is left raw so the uuid Conversion
-        // registered on the writer's data model (getAvroDataModel) renders it to a canonical string at write time.
-        Schema.Field avroField = avroSchema.getField(field);
-        if (avroField != null && avroField.schema().getType() == Schema.Type.BYTES) {
-          reusableRecord.put(field, ByteBuffer.wrap((byte[]) value));
-        } else {
-          reusableRecord.put(field, value);
-        }
-      } else {
+      Schema.Field avroField = avroSchema.getField(field);
+      if (avroField == null) {
+        // Let Avro raise its own "Not a valid schema field" error for a column missing from the Avro schema.
         reusableRecord.put(field, value);
+      } else {
+        reusableRecord.put(avroField.pos(), convertValue(avroField.schema(), value));
       }
     }
     return reusableRecord;
   }
 
-  /// Shared Avro data model with [UuidConversion] registered. Populated once at class initialization and never
-  /// mutated afterward (effectively immutable), so it is safe to share across writers.
+  /// Adapts a Pinot value to the representation the Avro writer expects for the given field schema, recursing into
+  /// array elements for multi-value columns.
+  @Nullable
+  private static Object convertValue(Schema fieldSchema, @Nullable Object value) {
+    if (value == null) {
+      return null;
+    }
+    if (value instanceof Object[]) {
+      Object[] values = (Object[]) value;
+      Schema elementSchema =
+          fieldSchema.getType() == Schema.Type.ARRAY ? fieldSchema.getElementType() : fieldSchema;
+      // Only BOOLEAN (stored int -> Boolean) and BYTES (byte[] -> ByteBuffer) element schemas can require a
+      // per-element transform. Every other MV element type is written as-is — INT/LONG/FLOAT/DOUBLE/STRING directly,
+      // and UUID (string element, raw byte[] rendered by the registered Conversion) — so hand the writer a zero-copy
+      // view over the existing array; allocating and copying a fresh list per row would be pure overhead on the
+      // segment-write hot path. (BIG_DECIMAL has a BYTES element schema and so takes the copy path below, but its
+      // BigDecimal values still pass through convertSingleValue unchanged for the registered Conversion.)
+      Schema.Type elementType = elementSchema.getType();
+      if (elementType != Schema.Type.BOOLEAN && elementType != Schema.Type.BYTES) {
+        return Arrays.asList(values);
+      }
+      List<Object> converted = new ArrayList<>(values.length);
+      for (Object singleValue : values) {
+        converted.add(convertSingleValue(elementSchema, singleValue));
+      }
+      return converted;
+    }
+    return convertSingleValue(fieldSchema, value);
+  }
+
+  /// Adapts a single (non-array) Pinot value to what `GenericDatumWriter` expects for `valueSchema`.
+  ///
+  /// Only two cases need fixing up; everything else is written as-is, either because the Pinot representation already
+  /// *is* the Avro representation (`Integer` for `int`, `Long` for `long{timestamp-millis}`, `String` for `string`)
+  /// or because a [Conversion] registered on [#getAvroDataModel] handles it (`byte[]` for `string{uuid}`,
+  /// [java.math.BigDecimal] for `bytes{big-decimal}`).
+  @Nullable
+  private static Object convertSingleValue(Schema valueSchema, @Nullable Object value) {
+    if (value == null) {
+      return null;
+    }
+    switch (valueSchema.getType()) {
+      case BOOLEAN:
+        // BOOLEAN is the one Pinot logical type with no Avro logical type to carry a Conversion, so its stored int
+        // 0/1 has to be coerced here. Values that are already Boolean (e.g. from a source that never went through
+        // Pinot's stored form) pass through.
+        return value instanceof Boolean ? value : ((Number) value).intValue() != 0;

Review Comment:
   Yes for the production call paths: transformed and segment-read BOOLEAN values are Integer, and plain BYTES values are byte[]. Simplified both to direct casts in dc7f174598. BIG_DECIMAL also has Avro base type BYTES but carries BigDecimal, so the conversion distinguishes the exact `big-decimal` logical schema.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org