Skip to content

Commit aa76592

Browse files
fix all compiler errors
1 parent 36bb731 commit aa76592

File tree

117 files changed

+3384
-2224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+3384
-2224
lines changed

airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/base/Destination.java

Lines changed: 0 additions & 1 deletion
This file was deleted.

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/CDKConstants.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ object CDKConstants {
1414
val prop = Properties()
1515

1616
try {
17-
CDKConstants::class.java.classLoader.getResourceAsStream("version.properties").use { inputStream ->
18-
prop.load(inputStream)
19-
return prop.getProperty("version")
20-
}
17+
CDKConstants::class
18+
.java
19+
.classLoader
20+
.getResourceAsStream("version.properties")
21+
.use { inputStream ->
22+
prop.load(inputStream)
23+
return prop.getProperty("version")
24+
}
2125
} catch (e: IOException) {
2226
throw RuntimeException("Could not read version properties file", e)
2327
}

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/DataTypeUtils.kt

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,44 @@ object DataTypeUtils {
2121

2222
const val DATE_FORMAT_WITH_MILLISECONDS_PATTERN: String = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
2323

24-
val TIME_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSSSSS")
25-
val TIMESTAMP_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
24+
@JvmField val TIME_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSSSSS")
25+
@JvmField
26+
val TIMESTAMP_FORMATTER: DateTimeFormatter =
27+
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
28+
@JvmField
2629
val TIMETZ_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSSSSSXXX")
27-
val TIMESTAMPTZ_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX")
28-
val OFFSETDATETIME_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS XXX")
29-
val DATE_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
30+
@JvmField
31+
val TIMESTAMPTZ_FORMATTER: DateTimeFormatter =
32+
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX")
33+
@JvmField
34+
val OFFSETDATETIME_FORMATTER: DateTimeFormatter =
35+
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS XXX")
36+
@JvmField val DATE_FORMATTER: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
3037

3138
@JvmStatic
3239
val dateFormat: DateFormat
33-
// wrap SimpleDateFormat in a function because SimpleDateFormat is not threadsafe as a static final.
34-
get() = SimpleDateFormat(DATE_FORMAT_PATTERN) // Quoted "Z" to indicate UTC, no timezone offset;
40+
// wrap SimpleDateFormat in a function because SimpleDateFormat is not threadsafe as a
41+
// static final.
42+
get() =
43+
SimpleDateFormat(DATE_FORMAT_PATTERN) // Quoted "Z" to indicate UTC, no timezone offset;
3544

3645
val dateFormatMillisPattern: DateFormat
37-
// wrap SimpleDateFormat in a function because SimpleDateFormat is not threadsafe as a static final.
46+
// wrap SimpleDateFormat in a function because SimpleDateFormat is not threadsafe as a
47+
// static final.
3848
get() = SimpleDateFormat(DATE_FORMAT_WITH_MILLISECONDS_PATTERN)
3949

4050
@JvmStatic
41-
fun <T> returnNullIfInvalid(valueProducer: DataTypeSupplier<T>): T {
42-
return returnNullIfInvalid(valueProducer, Function { ignored: T -> true })
51+
fun <T> returnNullIfInvalid(valueProducer: DataTypeSupplier<T>): T? {
52+
return returnNullIfInvalid(valueProducer, Function { _: T? -> true })
4353
}
4454

4555
@JvmStatic
46-
fun <T> returnNullIfInvalid(valueProducer: DataTypeSupplier<T>, isValidFn: Function<T?, Boolean>): T? {
47-
// Some edge case values (e.g: Infinity, NaN) have no java or JSON equivalent, and will throw an
56+
fun <T> returnNullIfInvalid(
57+
valueProducer: DataTypeSupplier<T>,
58+
isValidFn: Function<T?, Boolean>
59+
): T? {
60+
// Some edge case values (e.g: Infinity, NaN) have no java or JSON equivalent, and will
61+
// throw an
4862
// exception when parsed. We want to parse those
4963
// values as null.
5064
// This method reduces error handling boilerplate.
@@ -59,18 +73,21 @@ object DataTypeUtils {
5973
@JvmStatic
6074
fun toISO8601StringWithMicroseconds(instant: Instant): String {
6175
val dateWithMilliseconds = dateFormatMillisPattern.format(Date.from(instant))
62-
return dateWithMilliseconds.substring(0, 23) + calculateMicrosecondsString(instant.nano) + dateWithMilliseconds.substring(23)
76+
return dateWithMilliseconds.substring(0, 23) +
77+
calculateMicrosecondsString(instant.nano) +
78+
dateWithMilliseconds.substring(23)
6379
}
6480

6581
private fun calculateMicrosecondsString(nano: Int): String {
6682
val microSeconds = (nano / 1000) % 1000
67-
val result = if (microSeconds < 10) {
68-
"00$microSeconds"
69-
} else if (microSeconds < 100) {
70-
"0$microSeconds"
71-
} else {
72-
"" + microSeconds
73-
}
83+
val result =
84+
if (microSeconds < 10) {
85+
"00$microSeconds"
86+
} else if (microSeconds < 100) {
87+
"0$microSeconds"
88+
} else {
89+
"" + microSeconds
90+
}
7491
return result
7592
}
7693

@@ -110,6 +127,13 @@ object DataTypeUtils {
110127

111128
@JvmStatic
112129
fun toISO8601String(duration: Duration): String {
113-
return dateFormat.format(Date.from(Instant.ofEpochSecond(abs(duration.seconds.toDouble()).toLong(), abs(duration.nano.toDouble()).toLong())))
130+
return dateFormat.format(
131+
Date.from(
132+
Instant.ofEpochSecond(
133+
abs(duration.seconds.toDouble()).toLong(),
134+
abs(duration.nano.toDouble()).toLong()
135+
)
136+
)
137+
)
114138
}
115139
}

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/Database.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
*/
44
package io.airbyte.cdk.db
55

6+
import java.sql.SQLException
67
import org.jooq.Configuration
78
import org.jooq.DSLContext
89
import org.jooq.impl.DSL
9-
import java.sql.SQLException
1010

11-
/**
12-
* Database object for interacting with a Jooq connection.
13-
*/
14-
open class Database(private val dslContext: DSLContext) {
11+
/** Database object for interacting with a Jooq connection. */
12+
open class Database(private val dslContext: DSLContext?) {
1513
@Throws(SQLException::class)
1614
open fun <T> query(transform: ContextQueryFunction<T>): T? {
1715
return transform.query(dslContext)
1816
}
1917

2018
@Throws(SQLException::class)
2119
open fun <T> transaction(transform: ContextQueryFunction<T>): T? {
22-
return dslContext.transactionResult { configuration: Configuration? -> transform.query(DSL.using(configuration)) }
20+
return dslContext!!.transactionResult { configuration: Configuration? ->
21+
transform.query(DSL.using(configuration))
22+
}
2323
}
2424
}

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/ExceptionWrappingDatabase.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ package io.airbyte.cdk.db
66
import java.io.*
77
import java.sql.SQLException
88

9-
/**
10-
* Wraps a [Database] object and throwing IOExceptions instead of SQLExceptions.
11-
*/
9+
/** Wraps a [Database] object and throwing IOExceptions instead of SQLExceptions. */
1210
class ExceptionWrappingDatabase(private val database: Database) {
1311
@Throws(IOException::class)
1412
fun <T> query(transform: ContextQueryFunction<T>): T? {

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/IncrementalUtils.kt

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ object IncrementalUtils {
1818

1919
@JvmStatic
2020
fun getCursorField(stream: ConfiguredAirbyteStream): String {
21-
<<<<<<< HEAD
2221
check(stream.cursorField.size != 0) {
2322
"No cursor field specified for stream attempting to do incremental."
2423
}
2524
check(stream.cursorField.size <= 1) { "Source does not support nested cursor fields." }
2625
return stream.cursorField[0]
27-
=======
28-
check(stream.cursorField.size != 0) { "No cursor field specified for stream attempting to do incremental." }
29-
check(stream.cursorField.size <= 1) { "Source does not support nested cursor fields." }
30-
>>>>>>> 2d5d142d00 (convert java CDK core/main to kotlin)
3126
}
3227

3328
@JvmStatic
@@ -40,7 +35,6 @@ object IncrementalUtils {
4035
}
4136

4237
@JvmStatic
43-
<<<<<<< HEAD
4438
fun getCursorType(
4539
stream: ConfiguredAirbyteStream,
4640
cursorField: String?
@@ -77,20 +71,6 @@ object IncrementalUtils {
7771
.asText()
7872
.uppercase(Locale.getDefault())
7973
)
80-
=======
81-
fun getCursorType(stream: ConfiguredAirbyteStream, cursorField: String?): JsonSchemaPrimitiveUtil.JsonSchemaPrimitive? {
82-
checkNotNull(stream.stream.jsonSchema[PROPERTIES]) { String.format("No properties found in stream: %s.", stream.stream.name) }
83-
84-
checkNotNull(stream.stream.jsonSchema[PROPERTIES][cursorField]) { String.format("Could not find cursor field: %s in schema for stream: %s.", cursorField, stream.stream.name) }
85-
86-
check(!(stream.stream.jsonSchema[PROPERTIES][cursorField]["type"] == null &&
87-
stream.stream.jsonSchema[PROPERTIES][cursorField]["\$ref"] == null)) { String.format("Could not find cursor type for field: %s in schema for stream: %s.", cursorField, stream.stream.name) }
88-
89-
return if (stream.stream.jsonSchema[PROPERTIES][cursorField]["type"] == null) {
90-
JsonSchemaPrimitiveUtil.PRIMITIVE_TO_REFERENCE_BIMAP.inverse()[stream.stream.jsonSchema[PROPERTIES][cursorField]["\$ref"].asText()]
91-
} else {
92-
JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.valueOf(stream.stream.jsonSchema[PROPERTIES][cursorField]["type"].asText().uppercase(Locale.getDefault()))
93-
>>>>>>> 2d5d142d00 (convert java CDK core/main to kotlin)
9474
}
9575
}
9676

@@ -104,15 +84,11 @@ object IncrementalUtils {
10484
* @return
10585
*/
10686
@JvmStatic
107-
<<<<<<< HEAD
10887
fun compareCursors(
10988
original: String?,
11089
candidate: String?,
11190
type: JsonSchemaPrimitiveUtil.JsonSchemaPrimitive?
11291
): Int {
113-
=======
114-
fun compareCursors(original: String?, candidate: String?, type: JsonSchemaPrimitiveUtil.JsonSchemaPrimitive?): Int {
115-
>>>>>>> 2d5d142d00 (convert java CDK core/main to kotlin)
11692
if (original == null && candidate == null) {
11793
return 0
11894
}
@@ -126,7 +102,6 @@ object IncrementalUtils {
126102
}
127103

128104
return when (type) {
129-
<<<<<<< HEAD
130105
JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.STRING,
131106
JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.STRING_V1,
132107
JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.DATE_V1,
@@ -150,22 +125,6 @@ object IncrementalUtils {
150125
throw IllegalStateException(
151126
String.format("Cannot use field of type %s as a comparable", type)
152127
)
153-
=======
154-
JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.STRING, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.STRING_V1, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.DATE_V1, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.TIME_WITH_TIMEZONE_V1, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.TIME_WITHOUT_TIMEZONE_V1, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.TIMESTAMP_WITH_TIMEZONE_V1, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.TIMESTAMP_WITHOUT_TIMEZONE_V1 -> {
155-
original.compareTo(candidate)
156-
}
157-
158-
JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.NUMBER, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.NUMBER_V1, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.INTEGER_V1 -> {
159-
// todo (cgardens) - handle big decimal. this is currently an overflow risk.
160-
java.lang.Double.compare(original.toDouble(), candidate.toDouble())
161-
}
162-
163-
JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.BOOLEAN, JsonSchemaPrimitiveUtil.JsonSchemaPrimitive.BOOLEAN_V1 -> {
164-
Boolean.compare(original.toBoolean(), candidate.toBoolean())
165-
}
166-
167-
else -> throw IllegalStateException(String.format("Cannot use field of type %s as a comparable", type))
168-
>>>>>>> 2d5d142d00 (convert java CDK core/main to kotlin)
169128
}
170129
}
171130
}

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/JdbcCompatibleSourceOperations.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ interface JdbcCompatibleSourceOperations<SourceType> : SourceOperations<ResultSe
1414
* @param colIndex 1-based column index.
1515
*/
1616
@Throws(SQLException::class)
17-
fun copyToJsonField(resultSet: ResultSet, colIndex: Int, json: ObjectNode?)
17+
fun copyToJsonField(resultSet: ResultSet, colIndex: Int, json: ObjectNode)
1818

1919
/** Set the cursor field in incremental table query. */
2020
@Throws(SQLException::class)
2121
fun setCursorField(
2222
preparedStatement: PreparedStatement,
2323
parameterIndex: Int,
2424
cursorFieldType: SourceType?,
25-
value: String?
25+
value: String
2626
)
2727

2828
/** Determine the database specific type of the input field based on its column metadata. */

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/SourceOperations.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ interface SourceOperations<QueryResult, SourceType> {
1313
*
1414
* @throws SQLException
1515
*/
16-
@Throws(SQLException::class)
17-
fun rowToJson(queryResult: QueryResult): JsonNode
16+
@Throws(SQLException::class) fun rowToJson(queryResult: QueryResult): JsonNode
1817

1918
/**
2019
* Converts a database source type into an Airbyte type, which is currently represented by a

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/SqlDatabase.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import com.fasterxml.jackson.databind.JsonNode
77
import java.util.stream.Stream
88

99
abstract class SqlDatabase : AbstractDatabase() {
10-
@Throws(Exception::class)
11-
abstract fun execute(sql: String?)
10+
@Throws(Exception::class) abstract fun execute(sql: String?)
1211

1312
@Throws(Exception::class)
14-
abstract fun unsafeQuery(sql: String?, vararg params: String?): Stream<JsonNode?>
13+
abstract fun unsafeQuery(sql: String?, vararg params: String?): Stream<JsonNode>
1514
}

airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/db/factory/ConnectionFactory.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import java.util.*
1010

1111
/**
1212
* This class as been added in order to be able to save the connection in a test. It was found that
13-
* the [javax.sql.DataSource] close method wasn't propagating the connection properly. It
14-
* shouldn't be needed in our application code.
13+
* the [javax.sql.DataSource] close method wasn't propagating the connection properly. It shouldn't
14+
* be needed in our application code.
1515
*/
1616
object ConnectionFactory {
1717
/**
@@ -23,18 +23,19 @@ object ConnectionFactory {
2323
* @param jdbcConnectionString The JDBC connection string.
2424
* @return The configured [Connection]
2525
*/
26-
fun create(username: String?,
27-
password: String?,
28-
connectionProperties: Map<String?, String?>,
29-
jdbcConnectionString: String?): Connection {
26+
fun create(
27+
username: String?,
28+
password: String?,
29+
connectionProperties: Map<String?, String?>,
30+
jdbcConnectionString: String?
31+
): Connection {
3032
try {
3133
val properties = Properties()
3234
properties["user"] = username
3335
properties["password"] = password
3436
connectionProperties.forEach { (k: String?, v: String?) -> properties[k] = v }
3537

36-
return DriverManager.getConnection(jdbcConnectionString,
37-
properties)
38+
return DriverManager.getConnection(jdbcConnectionString, properties)
3839
} catch (e: SQLException) {
3940
throw RuntimeException(e)
4041
}

0 commit comments

Comments
 (0)