MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / allowTypeChange

Method allowTypeChange

src/common/types/value/value.cpp:951–994  ·  view source on GitHub ↗

Handle the case of casting empty list to a different type.

Source from the content-addressed store, hash-verified

949
950// Handle the case of casting empty list to a different type.
951bool Value::allowTypeChange() const {
952 if (isNull_ || !dataType.isInternalType()) {
953 return true;
954 }
955 switch (dataType.getLogicalTypeID()) {
956 case LogicalTypeID::ANY:
957 return true;
958 case LogicalTypeID::LIST:
959 case LogicalTypeID::ARRAY: {
960 if (childrenSize == 0) {
961 return true;
962 }
963 for (auto i = 0u; i < childrenSize; ++i) {
964 if (children[i]->allowTypeChange()) {
965 return true;
966 }
967 }
968 return false;
969 }
970 case LogicalTypeID::STRUCT: {
971 for (auto i = 0u; i < childrenSize; ++i) {
972 if (children[i]->allowTypeChange()) {
973 return true;
974 }
975 }
976 return false;
977 }
978 case LogicalTypeID::MAP: {
979 if (childrenSize == 0) {
980 return true;
981 }
982 for (auto i = 0u; i < childrenSize; ++i) {
983 auto k = children[i]->children[0].get();
984 auto v = children[i]->children[1].get();
985 if (k->allowTypeChange() || v->allowTypeChange()) {
986 return true;
987 }
988 }
989 return false;
990 }
991 default:
992 return false;
993 }
994}
995
996uint64_t Value::computeHash() const {
997 if (isNull_) {

Callers 2

castMethod · 0.80
tryCombineDataTypeMethod · 0.80

Calls 3

isInternalTypeMethod · 0.80
getLogicalTypeIDMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected