Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghislain Fourny committed Apr 18, 2024
1 parent e560494 commit 29b370b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 25 deletions.
9 changes: 9 additions & 0 deletions src/main/java/org/rumbledb/api/SequenceOfItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.apache.spark.SparkRuntimeException;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
Expand Down Expand Up @@ -207,6 +208,14 @@ public long populateListWithWarningOnlyIfCapReached(List<Item> resultList) {
RumbleException ex = new UnexpectedTypeException(e.getMessage(), ExceptionMetadata.EMPTY_METADATA);
ex.initCause(e);
throw ex;
} catch (SparkRuntimeException e) {
if (e.getMessage().contains("CAST_INVALID_INPUT")) {
RumbleException ex = new CastException(e.getMessage(), ExceptionMetadata.EMPTY_METADATA);
ex.initCause(e);
throw ex;
} else {
throw e;
}
} catch (UnsupportedOperationException e) {
RumbleException ex = new UnexpectedTypeException(e.getMessage(), ExceptionMetadata.EMPTY_METADATA);
ex.initCause(e);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/rumbledb/items/DateTimeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public DateTimeItem() {
DateTimeItem(String dateTimeString) {
this.value = parseDateTime(dateTimeString, BuiltinTypesCatalogue.dateTimeItem);
if (doesLexicalValueHaveNoTimeZone(dateTimeString)) {
System.err.println("No time zone.");
this.hasTimeZone = false;
this.value = this.value.withZoneRetainFields(DateTimeZone.UTC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,15 +833,6 @@ public static Dataset<Row> tryNativeQuery(
);
String selectSQL = FlworDataFrameUtils.getSQLColumnProjection(allColumns, true);
String input = FlworDataFrameUtils.createTempView(dataFrame);
System.err.println(
String.format(
"select %s %s as `%s` from %s",
selectSQL,
nativeQuery.getResultingQuery(),
newVariableName,
input
)
);
return dataFrame.sparkSession()
.sql(
String.format(
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/org/rumbledb/runtime/typing/CastIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "BOOLEAN" + ")) ";
System.err.println("Boolean");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.byteItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -850,7 +849,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "BYTE" + ")) ";
System.err.println("Byte");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.shortItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -865,7 +863,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "SHORT" + ")) ";
System.err.println("Short");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.intItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -880,7 +877,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "INT" + ")) ";
System.err.println("Int");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.longItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -895,7 +891,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "LONG" + ")) ";
System.err.println("Long");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.integerItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -910,7 +905,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "DECIMAL(38,0)" + ")) ";
System.err.println("Integer");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.decimalItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -925,7 +919,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "DECIMAL(38,19)" + ")) ";
System.err.println("Decimal");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.doubleItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -940,7 +933,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "DOUBLE" + ")) ";
System.err.println("Double");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.floatItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.booleanItem)
Expand All @@ -955,7 +947,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "FLOAT" + ")) ";
System.err.println("Float");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.stringItem)) {
if (this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.dateTimeStampItem)) {
return NativeClauseContext.NoNativeQuery;
Expand All @@ -974,7 +965,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
} else {
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "STRING" + ")) ";
}
System.err.println("String");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.anyURIItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.stringItem)
Expand All @@ -983,7 +973,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "STRING" + ")) ";
System.err.println("anyURI");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.dateItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.stringItem)
Expand All @@ -1000,7 +989,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "DATE" + ")) ";
System.err.println("Date");
} else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.dateTimeStampItem)) {
if (
!this.children.get(0).getStaticType().getItemType().equals(BuiltinTypesCatalogue.stringItem)
Expand All @@ -1014,7 +1002,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
return NativeClauseContext.NoNativeQuery;
}
resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "TIMESTAMP" + ")) ";
System.err.println("Timestamp");
/*
* } else if (this.sequenceType.getItemType().equals(BuiltinTypesCatalogue.hexBinaryItem)) {
* resultingQuery = " (CAST (" + value.getResultingQuery() + " AS " + "BINARY" + ")) ";
Expand All @@ -1023,7 +1010,6 @@ public NativeClauseContext generateNativeQuery(NativeClauseContext nativeClauseC
} else {
return NativeClauseContext.NoNativeQuery;
}
System.err.println("Return");
return new NativeClauseContext(
nativeClauseContext,
resultingQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ public void write(Kryo kryo, Output output) {
// kryo.writeObject(output, this.explicitTimezone);
}

@SuppressWarnings("unchecked")
@Override
public void read(Kryo kryo, Input input) {
this.name = kryo.readObject(input, Name.class);
Expand Down

0 comments on commit 29b370b

Please sign in to comment.