@@ -1567,6 +1567,100 @@ struct CustomType {
15671567 CustomType () {}
15681568};
15691569
1570+ struct Varbinary {
1571+ private:
1572+ Varbinary () {}
1573+ };
1574+ struct Varchar {
1575+ private:
1576+ Varchar () {}
1577+ };
1578+
1579+ template <typename T>
1580+ struct SimpleTypeTrait {};
1581+
1582+ template <>
1583+ struct SimpleTypeTrait <int64_t > : public TypeTraits<TypeKind::BIGINT> {};
1584+
1585+ template <>
1586+ struct SimpleTypeTrait <int32_t > : public TypeTraits<TypeKind::INTEGER> {};
1587+
1588+ template <>
1589+ struct SimpleTypeTrait <int16_t > : public TypeTraits<TypeKind::SMALLINT> {};
1590+
1591+ template <>
1592+ struct SimpleTypeTrait <int8_t > : public TypeTraits<TypeKind::TINYINT> {};
1593+
1594+ template <>
1595+ struct SimpleTypeTrait <float > : public TypeTraits<TypeKind::REAL> {};
1596+
1597+ template <>
1598+ struct SimpleTypeTrait <double > : public TypeTraits<TypeKind::DOUBLE> {};
1599+
1600+ template <>
1601+ struct SimpleTypeTrait <bool > : public TypeTraits<TypeKind::BOOLEAN> {};
1602+
1603+ template <>
1604+ struct SimpleTypeTrait <Varchar> : public TypeTraits<TypeKind::VARCHAR> {};
1605+
1606+ template <>
1607+ struct SimpleTypeTrait <Varbinary> : public TypeTraits<TypeKind::VARBINARY> {};
1608+
1609+ template <>
1610+ struct SimpleTypeTrait <Timestamp> : public TypeTraits<TypeKind::TIMESTAMP> {};
1611+
1612+ template <>
1613+ struct SimpleTypeTrait <Date> : public TypeTraits<TypeKind::DATE> {};
1614+
1615+ template <>
1616+ struct SimpleTypeTrait <IntervalDayTime>
1617+ : public TypeTraits<TypeKind::INTERVAL_DAY_TIME> {};
1618+
1619+ template <typename T>
1620+ struct SimpleTypeTrait <Generic<T>> {
1621+ static constexpr TypeKind typeKind = TypeKind::UNKNOWN;
1622+ static constexpr bool isPrimitiveType = false ;
1623+ static constexpr bool isFixedWidth = false ;
1624+ };
1625+
1626+ template <typename T>
1627+ struct SimpleTypeTrait <std::shared_ptr<T>>
1628+ : public TypeTraits<TypeKind::OPAQUE> {};
1629+
1630+ template <typename KEY, typename VAL>
1631+ struct SimpleTypeTrait <Map<KEY, VAL>> : public TypeTraits<TypeKind::MAP> {};
1632+
1633+ template <typename ELEMENT>
1634+ struct SimpleTypeTrait <Array<ELEMENT>> : public TypeTraits<TypeKind::ARRAY> {};
1635+
1636+ template <typename ... T>
1637+ struct SimpleTypeTrait <Row<T...>> : public TypeTraits<TypeKind::ROW> {};
1638+
1639+ template <>
1640+ struct SimpleTypeTrait <DynamicRow> : public TypeTraits<TypeKind::ROW> {};
1641+
1642+ template <>
1643+ struct SimpleTypeTrait <UnscaledShortDecimal>
1644+ : public TypeTraits<TypeKind::SHORT_DECIMAL> {};
1645+
1646+ template <>
1647+ struct SimpleTypeTrait <UnscaledLongDecimal>
1648+ : public TypeTraits<TypeKind::LONG_DECIMAL> {};
1649+
1650+ // T is also a simple type that represent the physical type of the custom type.
1651+ template <typename T>
1652+ struct SimpleTypeTrait <CustomType<T>>
1653+ : public SimpleTypeTrait<typename T::type> {
1654+ using physical_t = SimpleTypeTrait<typename T::type>;
1655+ static constexpr TypeKind typeKind = physical_t ::typeKind;
1656+ static constexpr bool isPrimitiveType = physical_t ::isPrimitiveType;
1657+ static constexpr bool isFixedWidth = physical_t ::isFixedWidth;
1658+
1659+ // This is different than the physical type name.
1660+ static constexpr char * name = T::typeName;
1661+ };
1662+
1663+ // TODO: move cppToType testing utilities.
15701664template <typename T>
15711665struct CppToType {};
15721666
@@ -1577,14 +1671,6 @@ struct CppToTypeBase : public TypeTraits<KIND> {
15771671 }
15781672};
15791673
1580- struct Varbinary {
1581- private:
1582- Varbinary () {}
1583- };
1584- struct Varchar {
1585- private:
1586- Varchar () {}
1587- };
15881674template <>
15891675struct CppToType <int64_t > : public CppToTypeBase<TypeKind::BIGINT> {};
15901676
0 commit comments