Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

[BAHIR-256] Fix ClassCastException in sql-streaming-mqtt #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ import org.eclipse.paho.client.mqttv3._

import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.sources.DataSourceRegister
import org.apache.spark.sql.sources.v2.{DataSourceOptions, DataSourceV2, MicroBatchReadSupport}
import org.apache.spark.sql.sources.v2.reader.{InputPartition, InputPartitionReader}
import org.apache.spark.sql.sources.v2.reader.streaming.{MicroBatchReader, Offset => OffsetV2}
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.UTF8String

import org.apache.bahir.utils.Logging

Expand Down Expand Up @@ -199,8 +201,12 @@ class MQTTStreamSource(options: DataSourceOptions, brokerUrl: String, persistenc
}

override def get(): InternalRow = {
InternalRow(slice(currentIdx).id, slice(currentIdx).topic,
slice(currentIdx).payload, slice(currentIdx).timestamp)
InternalRow(
slice(currentIdx).id,
UTF8String.fromString(slice(currentIdx).topic),
slice(currentIdx).payload,
DateTimeUtils.fromJavaTimestamp(slice(currentIdx).timestamp)
)
}

override def close(): Unit = {}
Expand Down