Java Code Examples for org.apache.spark.sql.Row#isNullAt()
The following examples show how to use
org.apache.spark.sql.Row#isNullAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListDataType.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; Object object = row.get(ordinal); deserialize((byte[]) object); } }
Example 2
Source File: SQLDouble.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; value = row.getDouble(ordinal); if (value == Double.POSITIVE_INFINITY || value == Double.NEGATIVE_INFINITY || value == Double.NaN) throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, TypeId.DOUBLE_NAME); } }
Example 3
Source File: SQLSmallint.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; value = row.getShort(ordinal); } }
Example 4
Source File: SQLLongint.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; value = row.getLong(ordinal); } }
Example 5
Source File: SQLTimestamp.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { Timestamp ts = row.getTimestamp(ordinal); setNumericTimestamp(ts,null); isNull = false; } }
Example 6
Source File: UserType.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; Object object = row.get(ordinal); if (object instanceof byte[]) { value = SerializationUtils.deserialize((byte[]) object); } else { value = object; } } }
Example 7
Source File: SQLRowId.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; bytes = (byte[]) row.get(ordinal); } }
Example 8
Source File: SQLBinary.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; dataValue = (byte[]) row.get(ordinal); } }
Example 9
Source File: SQLTime.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; encodedTime = computeEncodedTime(row.getTimestamp(ordinal)); encodedTimeFraction = 0; } }
Example 10
Source File: XML.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else xmlStringValue = new SQLChar(row.getString(ordinal)); }
Example 11
Source File: CheckForNullsRowRule.java From envelope with Apache License 2.0 | 5 votes |
@Override public boolean check(Row row) { for (String field : fields) { if (row.isNullAt(row.fieldIndex(field))) { return false; } } return true; }
Example 12
Source File: JavaUserDefinedUntypedAggregation.java From nemo with Apache License 2.0 | 5 votes |
/** * Updates the given aggregation buffer `buffer` with new input data from `input`. * * @param buffer buffer to update. * @param input input to update with. */ public void update(final MutableAggregationBuffer buffer, final Row input) { if (!input.isNullAt(0)) { long updatedSum = buffer.getLong(0) + input.getLong(0); long updatedCount = buffer.getLong(1) + 1; buffer.update(0, updatedSum); buffer.update(1, updatedCount); } }
Example 13
Source File: TestHelpers.java From iceberg with Apache License 2.0 | 5 votes |
private static Object getPrimitiveValue(Row row, int ord, Type type) { if (row.isNullAt(ord)) { return null; } switch (type.typeId()) { case BOOLEAN: return row.getBoolean(ord); case INTEGER: return row.getInt(ord); case LONG: return row.getLong(ord); case FLOAT: return row.getFloat(ord); case DOUBLE: return row.getDouble(ord); case STRING: return row.getString(ord); case BINARY: case FIXED: case UUID: return row.get(ord); case DATE: return row.getDate(ord); case TIMESTAMP: return row.getTimestamp(ord); case DECIMAL: return row.getDecimal(ord); default: throw new IllegalArgumentException("Unhandled type " + type); } }
Example 14
Source File: SQLRef.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { if (value == null) { value = new SQLRowId(); } value.read(row, ordinal); isNull = evaluateNull(); } }
Example 15
Source File: AllButEmptyStringAggregationFunction.java From bpmn.ai with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update(MutableAggregationBuffer buffer, Row input) { if (!input.isNullAt(0)) { String currentValue = (buffer.size() == 0 || buffer.getString(0) == null ? "" : buffer.getString(0)); String value = (currentValue.equals("") ? input.getString(0) : currentValue); buffer.update(0, value); } }
Example 16
Source File: SQLBoolean.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; value = row.getBoolean(ordinal); } }
Example 17
Source File: ProcessStatesAggregationFunction.java From bpmn.ai with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update(MutableAggregationBuffer buffer, Row input) { //TODO: only implemented for ACTIVE and COMPLETED state so far if (!input.isNullAt(0)) { String currentValue = (buffer.size() == 0 || buffer.getString(0) == null ? BpmnaiVariables.PROCESS_STATE_ACTIVE : buffer.getString(0)); String value = currentValue; if(!currentValue.equals(BpmnaiVariables.PROCESS_STATE_COMPLETED)){ if(input.getString(0).equals(BpmnaiVariables.PROCESS_STATE_COMPLETED)) { buffer.update(0, BpmnaiVariables.PROCESS_STATE_COMPLETED); } } } }
Example 18
Source File: SQLChar.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public void read(Row row, int ordinal) throws StandardException { if (row.isNullAt(ordinal)) setToNull(); else { isNull = false; value = row.getString(ordinal); } }
Example 19
Source File: SparkSqlInterpreter.java From Explorer with Apache License 2.0 | 4 votes |
@Override public InterpreterResult interpret(String st) { SQLContext sqlc = getSparkInterpreter().getSQLContext(); SparkContext sc = sqlc.sparkContext(); sc.setJobGroup(jobGroup, "Notebook", false); DataFrame dataFrame; Row[] rows = null; try { dataFrame = sqlc.sql(st); rows = dataFrame.take(maxResult + 1); } catch (Exception e) { logger.error("Error", e); sc.clearJobGroup(); return new InterpreterResult(Code.ERROR, e.getMessage()); } String msg = null; // get field names List<Attribute> columns = scala.collection.JavaConverters.asJavaListConverter( dataFrame.queryExecution().analyzed().output()).asJava(); for (Attribute col : columns) { if (msg == null) { msg = col.name(); } else { msg += "\t" + col.name(); } } msg += "\n"; // ArrayType, BinaryType, BooleanType, ByteType, DecimalType, DoubleType, DynamicType, FloatType, FractionalType, IntegerType, IntegralType, LongType, MapType, NativeType, NullType, NumericType, ShortType, StringType, StructType for (int r = 0; r < maxResult && r < rows.length; r++) { Row row = rows[r]; for (int i = 0; i < columns.size(); i++) { if (!row.isNullAt(i)) { msg += row.apply(i).toString(); } else { msg += "null"; } if (i != columns.size() - 1) { msg += "\t"; } } msg += "\n"; } if (rows.length > maxResult) { msg += "\n<font color=red>Results are limited by " + maxResult + ".</font>"; } InterpreterResult rett = new InterpreterResult(Code.SUCCESS, "%table " + msg); sc.clearJobGroup(); return rett; }
Example 20
Source File: DependencyLinkSpanIterator.java From zipkin-dependencies with Apache License 2.0 | 4 votes |
static @Nullable String emptyToNull(Row row, int index) { String result = row.isNullAt(index) ? null : row.getString(index); return result != null && !"".equals(result) ? result : null; }