Skip to content

Commit d7ed1fe

Browse files
committed
Use Field instead of Type to accommodate nested types
1 parent ebd4fc6 commit d7ed1fe

File tree

3 files changed

+28
-182
lines changed

3 files changed

+28
-182
lines changed

cpp/build-support/lint_exclusions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*_generated*
2+
*.grpc.fb.*
23
*parquet_constants.*
34
*parquet_types.*
45
*windows_compatibility.h

cpp/src/generated/ComputeIR_generated.h

Lines changed: 17 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,9 @@ struct Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
426426
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
427427
VT_SHAPE_TYPE = 4,
428428
VT_SHAPE = 6,
429-
VT_TYPE_TYPE = 8,
430-
VT_TYPE = 10,
431-
VT_BUFFERS = 12,
432-
VT_DICTIONARY = 14
429+
VT_FIELD = 8,
430+
VT_BUFFERS = 10,
431+
VT_DICTIONARY = 12
433432
};
434433
org::apache::arrow::flatbuf::computeir::Shape shape_type() const {
435434
return static_cast<org::apache::arrow::flatbuf::computeir::Shape>(GetField<uint8_t>(VT_SHAPE_TYPE, 0));
@@ -438,7 +437,7 @@ struct Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
438437
///
439438
/// Note that this is orthogonal to type and refers to the number
440439
/// of rows spanned by this Literal - a Literal may be Scalar shaped
441-
/// with multiple "columns" if `type` happens to be Struct.
440+
/// with multiple "columns" if the type happens to be Struct.
442441
const void *shape() const {
443442
return GetPointer<const void *>(VT_SHAPE);
444443
}
@@ -449,76 +448,10 @@ struct Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
449448
const org::apache::arrow::flatbuf::computeir::Scalar *shape_as_Scalar() const {
450449
return shape_type() == org::apache::arrow::flatbuf::computeir::Shape::Scalar ? static_cast<const org::apache::arrow::flatbuf::computeir::Scalar *>(shape()) : nullptr;
451450
}
452-
org::apache::arrow::flatbuf::Type type_type() const {
453-
return static_cast<org::apache::arrow::flatbuf::Type>(GetField<uint8_t>(VT_TYPE_TYPE, 0));
454-
}
455-
/// The type of this literal.
456-
const void *type() const {
457-
return GetPointer<const void *>(VT_TYPE);
458-
}
459-
template<typename T> const T *type_as() const;
460-
const org::apache::arrow::flatbuf::Null *type_as_Null() const {
461-
return type_type() == org::apache::arrow::flatbuf::Type::Null ? static_cast<const org::apache::arrow::flatbuf::Null *>(type()) : nullptr;
462-
}
463-
const org::apache::arrow::flatbuf::Int *type_as_Int() const {
464-
return type_type() == org::apache::arrow::flatbuf::Type::Int ? static_cast<const org::apache::arrow::flatbuf::Int *>(type()) : nullptr;
465-
}
466-
const org::apache::arrow::flatbuf::FloatingPoint *type_as_FloatingPoint() const {
467-
return type_type() == org::apache::arrow::flatbuf::Type::FloatingPoint ? static_cast<const org::apache::arrow::flatbuf::FloatingPoint *>(type()) : nullptr;
468-
}
469-
const org::apache::arrow::flatbuf::Binary *type_as_Binary() const {
470-
return type_type() == org::apache::arrow::flatbuf::Type::Binary ? static_cast<const org::apache::arrow::flatbuf::Binary *>(type()) : nullptr;
471-
}
472-
const org::apache::arrow::flatbuf::Utf8 *type_as_Utf8() const {
473-
return type_type() == org::apache::arrow::flatbuf::Type::Utf8 ? static_cast<const org::apache::arrow::flatbuf::Utf8 *>(type()) : nullptr;
474-
}
475-
const org::apache::arrow::flatbuf::Bool *type_as_Bool() const {
476-
return type_type() == org::apache::arrow::flatbuf::Type::Bool ? static_cast<const org::apache::arrow::flatbuf::Bool *>(type()) : nullptr;
477-
}
478-
const org::apache::arrow::flatbuf::Decimal *type_as_Decimal() const {
479-
return type_type() == org::apache::arrow::flatbuf::Type::Decimal ? static_cast<const org::apache::arrow::flatbuf::Decimal *>(type()) : nullptr;
480-
}
481-
const org::apache::arrow::flatbuf::Date *type_as_Date() const {
482-
return type_type() == org::apache::arrow::flatbuf::Type::Date ? static_cast<const org::apache::arrow::flatbuf::Date *>(type()) : nullptr;
483-
}
484-
const org::apache::arrow::flatbuf::Time *type_as_Time() const {
485-
return type_type() == org::apache::arrow::flatbuf::Type::Time ? static_cast<const org::apache::arrow::flatbuf::Time *>(type()) : nullptr;
486-
}
487-
const org::apache::arrow::flatbuf::Timestamp *type_as_Timestamp() const {
488-
return type_type() == org::apache::arrow::flatbuf::Type::Timestamp ? static_cast<const org::apache::arrow::flatbuf::Timestamp *>(type()) : nullptr;
489-
}
490-
const org::apache::arrow::flatbuf::Interval *type_as_Interval() const {
491-
return type_type() == org::apache::arrow::flatbuf::Type::Interval ? static_cast<const org::apache::arrow::flatbuf::Interval *>(type()) : nullptr;
492-
}
493-
const org::apache::arrow::flatbuf::List *type_as_List() const {
494-
return type_type() == org::apache::arrow::flatbuf::Type::List ? static_cast<const org::apache::arrow::flatbuf::List *>(type()) : nullptr;
495-
}
496-
const org::apache::arrow::flatbuf::Struct_ *type_as_Struct_() const {
497-
return type_type() == org::apache::arrow::flatbuf::Type::Struct_ ? static_cast<const org::apache::arrow::flatbuf::Struct_ *>(type()) : nullptr;
498-
}
499-
const org::apache::arrow::flatbuf::Union *type_as_Union() const {
500-
return type_type() == org::apache::arrow::flatbuf::Type::Union ? static_cast<const org::apache::arrow::flatbuf::Union *>(type()) : nullptr;
501-
}
502-
const org::apache::arrow::flatbuf::FixedSizeBinary *type_as_FixedSizeBinary() const {
503-
return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeBinary ? static_cast<const org::apache::arrow::flatbuf::FixedSizeBinary *>(type()) : nullptr;
504-
}
505-
const org::apache::arrow::flatbuf::FixedSizeList *type_as_FixedSizeList() const {
506-
return type_type() == org::apache::arrow::flatbuf::Type::FixedSizeList ? static_cast<const org::apache::arrow::flatbuf::FixedSizeList *>(type()) : nullptr;
507-
}
508-
const org::apache::arrow::flatbuf::Map *type_as_Map() const {
509-
return type_type() == org::apache::arrow::flatbuf::Type::Map ? static_cast<const org::apache::arrow::flatbuf::Map *>(type()) : nullptr;
510-
}
511-
const org::apache::arrow::flatbuf::Duration *type_as_Duration() const {
512-
return type_type() == org::apache::arrow::flatbuf::Type::Duration ? static_cast<const org::apache::arrow::flatbuf::Duration *>(type()) : nullptr;
513-
}
514-
const org::apache::arrow::flatbuf::LargeBinary *type_as_LargeBinary() const {
515-
return type_type() == org::apache::arrow::flatbuf::Type::LargeBinary ? static_cast<const org::apache::arrow::flatbuf::LargeBinary *>(type()) : nullptr;
516-
}
517-
const org::apache::arrow::flatbuf::LargeUtf8 *type_as_LargeUtf8() const {
518-
return type_type() == org::apache::arrow::flatbuf::Type::LargeUtf8 ? static_cast<const org::apache::arrow::flatbuf::LargeUtf8 *>(type()) : nullptr;
519-
}
520-
const org::apache::arrow::flatbuf::LargeList *type_as_LargeList() const {
521-
return type_type() == org::apache::arrow::flatbuf::Type::LargeList ? static_cast<const org::apache::arrow::flatbuf::LargeList *>(type()) : nullptr;
451+
/// The type of this literal. Field is used instead of Type to pick
452+
/// up child fields, dictionary encoding, etc.
453+
const org::apache::arrow::flatbuf::Field *field() const {
454+
return GetPointer<const org::apache::arrow::flatbuf::Field *>(VT_FIELD);
522455
}
523456
/// Buffers containing N elements of arrow-formatted data, where N
524457
/// is Array.length if shape is Array or 1 if shape is Scalar.
@@ -536,9 +469,8 @@ struct Literal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
536469
VerifyField<uint8_t>(verifier, VT_SHAPE_TYPE) &&
537470
VerifyOffsetRequired(verifier, VT_SHAPE) &&
538471
VerifyShape(verifier, shape(), shape_type()) &&
539-
VerifyField<uint8_t>(verifier, VT_TYPE_TYPE) &&
540-
VerifyOffsetRequired(verifier, VT_TYPE) &&
541-
VerifyType(verifier, type(), type_type()) &&
472+
VerifyOffsetRequired(verifier, VT_FIELD) &&
473+
verifier.VerifyTable(field()) &&
542474
VerifyOffset(verifier, VT_BUFFERS) &&
543475
verifier.VerifyVector(buffers()) &&
544476
verifier.VerifyVectorOfTables(buffers()) &&
@@ -556,90 +488,6 @@ template<> inline const org::apache::arrow::flatbuf::computeir::Scalar *Literal:
556488
return shape_as_Scalar();
557489
}
558490

559-
template<> inline const org::apache::arrow::flatbuf::Null *Literal::type_as<org::apache::arrow::flatbuf::Null>() const {
560-
return type_as_Null();
561-
}
562-
563-
template<> inline const org::apache::arrow::flatbuf::Int *Literal::type_as<org::apache::arrow::flatbuf::Int>() const {
564-
return type_as_Int();
565-
}
566-
567-
template<> inline const org::apache::arrow::flatbuf::FloatingPoint *Literal::type_as<org::apache::arrow::flatbuf::FloatingPoint>() const {
568-
return type_as_FloatingPoint();
569-
}
570-
571-
template<> inline const org::apache::arrow::flatbuf::Binary *Literal::type_as<org::apache::arrow::flatbuf::Binary>() const {
572-
return type_as_Binary();
573-
}
574-
575-
template<> inline const org::apache::arrow::flatbuf::Utf8 *Literal::type_as<org::apache::arrow::flatbuf::Utf8>() const {
576-
return type_as_Utf8();
577-
}
578-
579-
template<> inline const org::apache::arrow::flatbuf::Bool *Literal::type_as<org::apache::arrow::flatbuf::Bool>() const {
580-
return type_as_Bool();
581-
}
582-
583-
template<> inline const org::apache::arrow::flatbuf::Decimal *Literal::type_as<org::apache::arrow::flatbuf::Decimal>() const {
584-
return type_as_Decimal();
585-
}
586-
587-
template<> inline const org::apache::arrow::flatbuf::Date *Literal::type_as<org::apache::arrow::flatbuf::Date>() const {
588-
return type_as_Date();
589-
}
590-
591-
template<> inline const org::apache::arrow::flatbuf::Time *Literal::type_as<org::apache::arrow::flatbuf::Time>() const {
592-
return type_as_Time();
593-
}
594-
595-
template<> inline const org::apache::arrow::flatbuf::Timestamp *Literal::type_as<org::apache::arrow::flatbuf::Timestamp>() const {
596-
return type_as_Timestamp();
597-
}
598-
599-
template<> inline const org::apache::arrow::flatbuf::Interval *Literal::type_as<org::apache::arrow::flatbuf::Interval>() const {
600-
return type_as_Interval();
601-
}
602-
603-
template<> inline const org::apache::arrow::flatbuf::List *Literal::type_as<org::apache::arrow::flatbuf::List>() const {
604-
return type_as_List();
605-
}
606-
607-
template<> inline const org::apache::arrow::flatbuf::Struct_ *Literal::type_as<org::apache::arrow::flatbuf::Struct_>() const {
608-
return type_as_Struct_();
609-
}
610-
611-
template<> inline const org::apache::arrow::flatbuf::Union *Literal::type_as<org::apache::arrow::flatbuf::Union>() const {
612-
return type_as_Union();
613-
}
614-
615-
template<> inline const org::apache::arrow::flatbuf::FixedSizeBinary *Literal::type_as<org::apache::arrow::flatbuf::FixedSizeBinary>() const {
616-
return type_as_FixedSizeBinary();
617-
}
618-
619-
template<> inline const org::apache::arrow::flatbuf::FixedSizeList *Literal::type_as<org::apache::arrow::flatbuf::FixedSizeList>() const {
620-
return type_as_FixedSizeList();
621-
}
622-
623-
template<> inline const org::apache::arrow::flatbuf::Map *Literal::type_as<org::apache::arrow::flatbuf::Map>() const {
624-
return type_as_Map();
625-
}
626-
627-
template<> inline const org::apache::arrow::flatbuf::Duration *Literal::type_as<org::apache::arrow::flatbuf::Duration>() const {
628-
return type_as_Duration();
629-
}
630-
631-
template<> inline const org::apache::arrow::flatbuf::LargeBinary *Literal::type_as<org::apache::arrow::flatbuf::LargeBinary>() const {
632-
return type_as_LargeBinary();
633-
}
634-
635-
template<> inline const org::apache::arrow::flatbuf::LargeUtf8 *Literal::type_as<org::apache::arrow::flatbuf::LargeUtf8>() const {
636-
return type_as_LargeUtf8();
637-
}
638-
639-
template<> inline const org::apache::arrow::flatbuf::LargeList *Literal::type_as<org::apache::arrow::flatbuf::LargeList>() const {
640-
return type_as_LargeList();
641-
}
642-
643491
struct LiteralBuilder {
644492
typedef Literal Table;
645493
flatbuffers::FlatBufferBuilder &fbb_;
@@ -650,11 +498,8 @@ struct LiteralBuilder {
650498
void add_shape(flatbuffers::Offset<void> shape) {
651499
fbb_.AddOffset(Literal::VT_SHAPE, shape);
652500
}
653-
void add_type_type(org::apache::arrow::flatbuf::Type type_type) {
654-
fbb_.AddElement<uint8_t>(Literal::VT_TYPE_TYPE, static_cast<uint8_t>(type_type), 0);
655-
}
656-
void add_type(flatbuffers::Offset<void> type) {
657-
fbb_.AddOffset(Literal::VT_TYPE, type);
501+
void add_field(flatbuffers::Offset<org::apache::arrow::flatbuf::Field> field) {
502+
fbb_.AddOffset(Literal::VT_FIELD, field);
658503
}
659504
void add_buffers(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::computeir::InlineBuffer>>> buffers) {
660505
fbb_.AddOffset(Literal::VT_BUFFERS, buffers);
@@ -671,7 +516,7 @@ struct LiteralBuilder {
671516
const auto end = fbb_.EndTable(start_);
672517
auto o = flatbuffers::Offset<Literal>(end);
673518
fbb_.Required(o, Literal::VT_SHAPE);
674-
fbb_.Required(o, Literal::VT_TYPE);
519+
fbb_.Required(o, Literal::VT_FIELD);
675520
return o;
676521
}
677522
};
@@ -680,16 +525,14 @@ inline flatbuffers::Offset<Literal> CreateLiteral(
680525
flatbuffers::FlatBufferBuilder &_fbb,
681526
org::apache::arrow::flatbuf::computeir::Shape shape_type = org::apache::arrow::flatbuf::computeir::Shape::NONE,
682527
flatbuffers::Offset<void> shape = 0,
683-
org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE,
684-
flatbuffers::Offset<void> type = 0,
528+
flatbuffers::Offset<org::apache::arrow::flatbuf::Field> field = 0,
685529
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<org::apache::arrow::flatbuf::computeir::InlineBuffer>>> buffers = 0,
686530
flatbuffers::Offset<org::apache::arrow::flatbuf::computeir::Literal> dictionary = 0) {
687531
LiteralBuilder builder_(_fbb);
688532
builder_.add_dictionary(dictionary);
689533
builder_.add_buffers(buffers);
690-
builder_.add_type(type);
534+
builder_.add_field(field);
691535
builder_.add_shape(shape);
692-
builder_.add_type_type(type_type);
693536
builder_.add_shape_type(shape_type);
694537
return builder_.Finish();
695538
}
@@ -698,17 +541,15 @@ inline flatbuffers::Offset<Literal> CreateLiteralDirect(
698541
flatbuffers::FlatBufferBuilder &_fbb,
699542
org::apache::arrow::flatbuf::computeir::Shape shape_type = org::apache::arrow::flatbuf::computeir::Shape::NONE,
700543
flatbuffers::Offset<void> shape = 0,
701-
org::apache::arrow::flatbuf::Type type_type = org::apache::arrow::flatbuf::Type::NONE,
702-
flatbuffers::Offset<void> type = 0,
544+
flatbuffers::Offset<org::apache::arrow::flatbuf::Field> field = 0,
703545
const std::vector<flatbuffers::Offset<org::apache::arrow::flatbuf::computeir::InlineBuffer>> *buffers = nullptr,
704546
flatbuffers::Offset<org::apache::arrow::flatbuf::computeir::Literal> dictionary = 0) {
705547
auto buffers__ = buffers ? _fbb.CreateVector<flatbuffers::Offset<org::apache::arrow::flatbuf::computeir::InlineBuffer>>(*buffers) : 0;
706548
return org::apache::arrow::flatbuf::computeir::CreateLiteral(
707549
_fbb,
708550
shape_type,
709551
shape,
710-
type_type,
711-
type,
552+
field,
712553
buffers__,
713554
dictionary);
714555
}

format/ComputeIR.fbs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ table Literal {
5656
///
5757
/// Note that this is orthogonal to type and refers to the number
5858
/// of rows spanned by this Literal - a Literal may be Scalar shaped
59-
/// with multiple "columns" if `type` happens to be Struct.
59+
/// with multiple "columns" if the type happens to be Struct.
6060
shape: Shape (required);
6161

62-
/// The type of this literal.
63-
type: Type (required);
62+
/// The type of this literal. Field is used instead of Type to pick
63+
/// up child fields, dictionary encoding, etc.
64+
field: Field (required);
6465

6566
/// Buffers containing N elements of arrow-formatted data, where N
6667
/// is Array.length if shape is Array or 1 if shape is Scalar.
@@ -82,8 +83,9 @@ table FieldRef {
8283
/// 0 refers to the left relation and 1 to the right relation.
8384
relation_index: int;
8485

85-
/// The type of data in the referenced Field.
86-
type: Type;
86+
/// The type of the referenced Field. Field is used instead of Type to pick
87+
/// up child fields, dictionary encoding, etc.
88+
field: Field;
8789
}
8890

8991
table Call {
@@ -101,7 +103,9 @@ table Call {
101103
arguments: [Expression] (required);
102104

103105
/// The type of data which invoking `function_name` will return.
104-
type: Type;
106+
/// Field is used instead of Type to pick up child fields,
107+
/// dictionary encoding, etc.
108+
field: Field;
105109
}
106110

107111
/// A relation is a set of rows with consistent schema.

0 commit comments

Comments
 (0)