Skip to content

Commit d7a543b

Browse files
authored
Minor updates to ExtractJSON feature validation & logging (#291)
1 parent da0ac71 commit d7a543b

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/main/java/com/datastax/cdm/cql/statement/TargetInsertStatement.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
*/
1616
package com.datastax.cdm.cql.statement;
1717

18+
import java.time.Duration;
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
24+
1825
import com.datastax.cdm.cql.EnhancedSession;
1926
import com.datastax.cdm.properties.IPropertyHelper;
2027
import com.datastax.cdm.properties.KnownProperties;
2128
import com.datastax.cdm.properties.PropertyHelper;
2229
import com.datastax.oss.driver.api.core.cql.BoundStatement;
2330
import com.datastax.oss.driver.api.core.cql.Row;
24-
import org.slf4j.Logger;
25-
import org.slf4j.LoggerFactory;
26-
27-
import java.util.ArrayList;
28-
import java.util.List;
29-
import java.time.Duration;
3031

3132
public class TargetInsertStatement extends TargetUpsertStatement {
3233
public final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@@ -75,12 +76,12 @@ protected BoundStatement bind(Row originRow, Row targetRow, Integer ttl, Long wr
7576

7677
boundStatement = boundStatement.set(currentBindIndex++, bindValue, cqlTable.getBindClass(targetIndex));
7778
} catch (Exception e) {
78-
logger.error("Error trying to bind value:" + bindValue + " of class:"
79-
+ (null == bindValue ? "unknown" : bindValue.getClass().getName()) + " to column:"
80-
+ targetColumnNames.get(targetIndex) + " of targetDataType:"
81-
+ targetColumnTypes.get(targetIndex) + "/" + cqlTable.getBindClass(targetIndex).getName()
82-
+ " at column index:" + targetIndex + " and bind index: " + (currentBindIndex - 1)
83-
+ " of statement:" + this.getCQL());
79+
logger.error(
80+
"Error trying to bind value: {} of class: {} to column: {} of targetDataType: {}/{} at column index: {} and bind index: {} of statement: {}",
81+
bindValue, (null == bindValue ? "unknown" : bindValue.getClass().getName()),
82+
targetColumnNames.get(targetIndex), targetColumnTypes.get(targetIndex),
83+
cqlTable.getBindClass(targetIndex).getName(), targetIndex, (currentBindIndex - 1),
84+
this.getCQL());
8485
throw new RuntimeException("Error trying to bind value: ", e);
8586
}
8687
}

src/main/java/com/datastax/cdm/feature/ExtractJson.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,16 @@ public boolean loadProperties(IPropertyHelper helper) {
6969

7070
@Override
7171
protected boolean validateProperties() {
72-
if ((null == originColumnName || originColumnName.isEmpty())
73-
&& (null == targetColumnName || targetColumnName.isEmpty()))
72+
if (StringUtils.isBlank(originColumnName) && StringUtils.isBlank(targetColumnName))
7473
return true;
7574

76-
if (null == originColumnName || originColumnName.isEmpty()) {
77-
logger.error("Origin column name is not set when Target ({}) are set", targetColumnName);
75+
if (StringUtils.isBlank(originColumnName)) {
76+
logger.error("Origin column name is not set when Target ({}) is set", targetColumnName);
7877
return false;
7978
}
8079

81-
if (null == targetColumnName || targetColumnName.isEmpty()) {
82-
logger.error("Target column name is not set when Origin ({}) are set", originColumnName);
80+
if (StringUtils.isBlank(targetColumnName)) {
81+
logger.error("Target column name is not set when Origin ({}) is set", originColumnName);
8382
return false;
8483
}
8584

0 commit comments

Comments
 (0)