Skip to content

Commit

Permalink
Minor updates to ExtractJSON feature validation & logging
Browse files Browse the repository at this point in the history
  • Loading branch information
msmygit committed Aug 26, 2024
1 parent da0ac71 commit 5513bd8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
*/
package com.datastax.cdm.cql.statement;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.datastax.cdm.cql.EnhancedSession;
import com.datastax.cdm.properties.IPropertyHelper;
import com.datastax.cdm.properties.KnownProperties;
import com.datastax.cdm.properties.PropertyHelper;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.Row;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.time.Duration;

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

boundStatement = boundStatement.set(currentBindIndex++, bindValue, cqlTable.getBindClass(targetIndex));
} catch (Exception e) {
logger.error("Error trying to bind value:" + bindValue + " of class:"
+ (null == bindValue ? "unknown" : bindValue.getClass().getName()) + " to column:"
+ targetColumnNames.get(targetIndex) + " of targetDataType:"
+ targetColumnTypes.get(targetIndex) + "/" + cqlTable.getBindClass(targetIndex).getName()
+ " at column index:" + targetIndex + " and bind index: " + (currentBindIndex - 1)
+ " of statement:" + this.getCQL());
logger.error(
"Error trying to bind value: {} of class: {} to column: {} of targetDataType: {}/{} at column index: {} and bind index: {} of statement: {}",
bindValue, (null == bindValue ? "unknown" : bindValue.getClass().getName()),
targetColumnNames.get(targetIndex), targetColumnTypes.get(targetIndex),
cqlTable.getBindClass(targetIndex).getName(), targetIndex, (currentBindIndex - 1),
this.getCQL());
throw new RuntimeException("Error trying to bind value: ", e);
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/datastax/cdm/feature/ExtractJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,16 @@ public boolean loadProperties(IPropertyHelper helper) {

@Override
protected boolean validateProperties() {
if ((null == originColumnName || originColumnName.isEmpty())
&& (null == targetColumnName || targetColumnName.isEmpty()))
if (StringUtils.isBlank(originColumnName) && StringUtils.isBlank(targetColumnName))
return true;

if (null == originColumnName || originColumnName.isEmpty()) {
logger.error("Origin column name is not set when Target ({}) are set", targetColumnName);
if (StringUtils.isBlank(originColumnName)) {
logger.error("Origin column name is not set when Target ({}) is set", targetColumnName);
return false;
}

if (null == targetColumnName || targetColumnName.isEmpty()) {
logger.error("Target column name is not set when Origin ({}) are set", originColumnName);
if (StringUtils.isBlank(targetColumnName)) {
logger.error("Target column name is not set when Origin ({}) is set", originColumnName);
return false;
}

Expand Down

0 comments on commit 5513bd8

Please sign in to comment.