Tabnine Logo
SqlUtils.stringLiteral
Code IndexAdd Tabnine to your IDE (free)

How to use
stringLiteral
method
in
com.dremio.common.utils.SqlUtils

Best Java code snippets using com.dremio.common.utils.SqlUtils.stringLiteral (Showing top 14 results out of 315)

origin: dremio/dremio-oss

 private String quoteLiteral(String value, DataType type) {
  if (type == DataType.TEXT) {
   return stringLiteral(value);
  } else if (type == DataType.DATE) {
   return "DATE " + stringLiteral(value);
  } else if (type == DataType.TIME) {
   return "TIME " + stringLiteral(value);
  } else if (type == DataType.DATETIME) {
   return "TIMESTAMP " + stringLiteral(value);
  }

  return value;
 }
}
origin: dremio/dremio-oss

private String quoted(String value, DataType type) {
 if (type == null || type == TEXT) {
  return stringLiteral(value);
 } else if (type == DATE) {
  if (value == null) {
   return "CAST (null as DATE)";
  }
  return "DATE " + stringLiteral(value);
 } else if (type == TIME) {
  if (value == null) {
   return "CAST (null as TIME)";
  }
  return "TIME " + stringLiteral(value);
 } else if (type == DATETIME) {
  if (value == null) {
   return "CAST (null as TIMESTAMP)";
  }
  return "TIMESTAMP " + stringLiteral(value);
 } else {
  return value;
 }
}
origin: dremio/dremio-oss

private String prepareValue(final String value, DataType type) throws Exception {
 if (value == null) {
  return "NULL";
 }
 switch (type) {
  case BOOLEAN:
  case DECIMAL:
  case FLOAT:
  case INTEGER:
   return value;
  case DATE:
  case DATETIME:
  case TEXT:
  case TIME:
   return stringLiteral(value);
  default:
   throw new UnsupportedOperationException("prepareValue can not be aplied to " + type.name());
 }
}
origin: dremio/dremio-oss

@Override
public String getFunctionExpr(String expr, Object... args) {
 checkArgument(args.length == 2 && args[0] != null && args[1] != null, "Expected the split position type and index as arguments");
 SplitPositionType splitPositionType = (SplitPositionType) args[0];
 Integer index = (Integer) args[1];
 return String.format("%s(%s, %s, %s, %d)",
   SplitPattern.REGEXP_SPLIT,
   expr,
   getDelimiterRegexLiteral(false),
   stringLiteral(splitPositionType.toString()),
   index
 );
}
origin: dremio/dremio-oss

@Override
public String visit(FieldConvertDateToText dateToText) throws Exception {
 return format(
   "TO_CHAR(%s, %s)",
   eval(fieldTransformation.getOperand()),
   stringLiteral(dateToText.getFormat()));
}
origin: dremio/dremio-oss

@Override
public String visit(FieldConvertListToText listToText) throws Exception {
 return format(
   "%s(%s, %s)",
   FormatList.NAME,
   eval(fieldTransformation.getOperand()),
   stringLiteral(listToText.getDelimiter()));
}
origin: dremio/dremio-oss

private String getMatchFunction(String expr) {
 // Generate the match function
 if (rule.getSelectionType() == IS_NULL) {
  return String.format("%s IS NULL", expr);
 } else if (rule.getSelectionType() == EXACT) {
  if (rule.getIgnoreCase() != null && rule.getIgnoreCase()) {
   return String.format("lower(%s) = lower(%s)", expr, stringLiteral(rule.getSelectionPattern()));
  } else {
   return String.format("%s = %s", expr, stringLiteral(rule.getSelectionPattern()));
  }
 } else {
  String patternLiteral = getRegexPatternLiteral(true);
  return String.format("regexp_like(%s, %s)", expr, patternLiteral);
 }
}
origin: dremio/dremio-oss

private String getFunction(String functionName, String inputExpr) {
 ExtractRulePattern patternRule = rule.getPattern();
 String pattern = patternRule.getPattern();
 if (patternRule.getIgnoreCase() != null && patternRule.getIgnoreCase()) {
  pattern = "(?i)(?u)" + pattern;
 }
 return String.format("%s(%s, %s, %d, %s)",
   functionName,
   inputExpr,
   stringLiteral(pattern),
   patternRule.getIndex(),
   stringLiteral(patternRule.getIndexType().name())
 );
}
origin: dremio/dremio-oss

final TextFileConfig textFileConfig = (TextFileConfig)this;
stringBuilder.append("type => 'text', ");
stringBuilder.append(format("fieldDelimiter => %s, ", SqlUtils.stringLiteral(textFileConfig.getFieldDelimiter())));
stringBuilder.append(format("comment => %s, ", SqlUtils.stringLiteral(singleChar(textFileConfig.getComment()))));
stringBuilder.append(format("%1$sescape%1$s => %2$s, ", SqlUtils.QUOTE, SqlUtils.stringLiteral(singleChar(textFileConfig.getEscape()))));
stringBuilder.append(format("quote => %s, ", SqlUtils.stringLiteral(singleChar(textFileConfig.getQuote()))));
stringBuilder.append(format("lineDelimiter => %s, ", SqlUtils.stringLiteral(textFileConfig.getLineDelimiter())));
stringBuilder.append(format("extractHeader => %s, ", textFileConfig.getExtractHeader().toString()));
stringBuilder.append(format("skipFirstLine => %s, ", textFileConfig.getSkipFirstLine().toString()));
stringBuilder.append("type => 'excel', ");
if (excelFileConfig.getSheetName() != null) {
 stringBuilder.append(format("sheet => %s, ", SqlUtils.stringLiteral(excelFileConfig.getSheetName())));
stringBuilder.append("type => 'excel', ");
if (xlsFileConfig.getSheetName() != null) {
 stringBuilder.append(format("sheet => %s, ", SqlUtils.stringLiteral(xlsFileConfig.getSheetName())));
origin: dremio/dremio-oss

@Override
public String visit(FieldConvertTextToDate textToDate) throws Exception {
 String op = eval(fieldTransformation.getOperand());
 String dateFormat = stringLiteral(textToDate.getFormat());
 DataType desiredType = textToDate.getDesiredType();
 switch (desiredType) {
  case DATE:
  case DATETIME:
  case TIME:
   return format("TO_%s(%s, %s)", DataTypeUtil.getStringValueForDateType(desiredType), op, dateFormat);
 default:
  throw new IllegalArgumentException("only DATE, TIME and DATETIME ar valid. Got " + desiredType);
 }
}
origin: dremio/dremio-oss

@Override
public String getExampleFunctionExpr(String input) {
 final boolean ignoreCase = rule.getIgnoreCase() == null ? false : rule.getIgnoreCase();
 final String quotedPattern = stringLiteral(rule.getSelectionPattern());
 return String.format("%s(%s, '%s', %s, %s)", MatchPattern.GEN_EXAMPLE, input,
   rule.getSelectionType().toString(), quotedPattern, ignoreCase);
}
origin: dremio/dremio-oss

if (replaceType != ReplaceType.NULL) {
 checkArgument(args.length == 2 && args[1] != null, "Expected the replacement value as second argument");
 replacementValue = stringLiteral((String)args[1]);
origin: dremio/dremio-oss

private String getRegexPatternLiteral(boolean forMatch) {
 final String patternLiteral = rule.getSelectionPattern();
 String regexp;
 switch (rule.getSelectionType()) {
  case CONTAINS:
   regexp = regexp(forMatch) + quote(patternLiteral) + regexp(forMatch);
   break;
  case STARTS_WITH:
   regexp = "^" + quote(patternLiteral) + regexp(forMatch);
   break;
  case ENDS_WITH:
   regexp = regexp(forMatch) + quote(patternLiteral) + "$";
   break;
  case MATCHES:
   regexp = regexp(forMatch) + patternLiteral + regexp(forMatch);
   break;
  default:
   throw UserException.unsupportedError()
     .message("regexp not available for selection type: " + rule.getSelectionType().toString())
     .build(logger);
 }
 if (rule.getIgnoreCase() != null && rule.getIgnoreCase()) {
  // make the pattern case insensitive and unicode case aware
  regexp = "(?i)(?u)" + regexp;
 }
 return stringLiteral(regexp);
}
origin: dremio/dremio-oss

 private String getDelimiterRegexLiteral(boolean forMatching) {
  String regexp;
  switch (rule.getMatchType()) {
   case exact:
    regexp = quote(rule.getPattern());
    break;
   case regex:
    regexp = rule.getPattern();
    break;
   default:
    throw UserException.unsupportedError()
      .message("unsupported selection type: " + rule.getMatchType().toString())
      .build(logger);
  }
  if (forMatching) {
   regexp = ".*" + regexp + ".*";
  }
  if (rule.getIgnoreCase() != null && rule.getIgnoreCase()) {
   // make the pattern case insensitive and unicode case aware
   regexp = "(?i)(?u)" + regexp;
  }
  return stringLiteral(regexp);
 }
}
com.dremio.common.utilsSqlUtilsstringLiteral

Javadoc

Convert given string value as string literal in SQL.

Popular methods of SqlUtils

  • quoteIdentifier
    quote the identifier if it is a: - doesn't start with a character, - contains non-alphanumeric chara
  • isKeyword
    Is the given id a reserved keyword?
  • parseSchemaPath
    Parse the schema path into a list of schema entries.
  • quotedCompound
  • quoteString
  • quoteUnicodeString

Popular in Java

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • setScale (BigDecimal)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now