in cassandra-analytics-spark-four-zero-converter/src/main/java/org/apache/cassandra/spark/data/converter/SparkSqlTypeConverterImplementation.java [144:189]
protected static SparkType getOrThrow(CqlField.CqlType cqlType)
{
if (cqlType == null)
{
throw new NullPointerException("Null CqlType provided");
}
SparkType nativeSparkType = NATIVE_TYPES.get(cqlType.getClass());
if (nativeSparkType != null)
{
return nativeSparkType;
}
if (cqlType.isFrozen())
{
// frozen type has no equivalent in SparkSQL so unpack inner
return new SparkFrozen(INSTANCE, ((CqlField.CqlFrozen) cqlType).inner());
}
if (cqlType.isComplex())
{
if (cqlType instanceof CqlField.CqlSet)
{
return new SparkSet(INSTANCE, (CqlField.CqlSet) cqlType);
}
else if (cqlType instanceof CqlField.CqlList)
{
return new SparkList(INSTANCE, (CqlField.CqlList) cqlType);
}
else if (cqlType instanceof CqlField.CqlMap)
{
return new SparkMap(INSTANCE, (CqlField.CqlMap) cqlType);
}
else if (cqlType instanceof CqlField.CqlTuple)
{
return new SparkTuple(INSTANCE, (CqlField.CqlTuple) cqlType);
}
else if (cqlType instanceof CqlField.CqlUdt)
{
return new SparkUdt(INSTANCE, (CqlField.CqlUdt) cqlType);
}
throw new IllegalStateException("Unexpected complex type: " + cqlType);
}
return Objects.requireNonNull(nativeSparkType, String.format("No mapping from %s Cql native type to Spark type", cqlType.getClass().getName()));
}