private def createBoundStatement()

in cassandra/src/main/scala/org/apache/zeppelin/cassandra/InterpreterLogic.scala [403:442]


  private def createBoundStatement(codecRegistry: CodecRegistry, name: String, ps: PreparedStatement,
                                   rawBoundValues: String): BoundStatement = {
    val dataTypes = ps.getVariableDefinitions.iterator.asScala.toSeq.map(cfDef => cfDef.getType)

    val boundValuesAsText = parseBoundValues(name,rawBoundValues)

    if(dataTypes.size != boundValuesAsText.size) throw new InterpreterException(s"Invalid @bind values for prepared statement '$name'. " +
      s"Prepared parameters has ${dataTypes.size} variables whereas bound values have ${boundValuesAsText.size} parameters ...")

    val convertedValues: List[AnyRef] = boundValuesAsText
      .zip(dataTypes).map {
        case (value, dataType) =>
          if(value.trim == "null") {
            null
          } else {
            val codec: TypeCodec[AnyRef] = codecRegistry.codecFor[AnyRef](dataType)
            dataType match {
            case ASCII | TEXT  => value.trim.replaceAll("(?<!')'","")
            case INT | VARINT => value.trim.toInt
            case BIGINT | COUNTER => value.trim.toLong
            case BLOB => ByteBuffer.wrap(value.trim.getBytes)
            case BOOLEAN => value.trim.toBoolean
            case DECIMAL => BigDecimal(value.trim)
            case DOUBLE => value.trim.toDouble
            case FLOAT => value.trim.toFloat
            case INET => InetAddress.getByName(value.trim)
            case TIMESTAMP => parseDate(value.trim)
            case UUID | TIMEUUID => java.util.UUID.fromString(value.trim)
            case _: ListType => codec.parse(boundValuesParser.parse(boundValuesParser.list, value).get)
            case _: SetType => codec.parse(boundValuesParser.parse(boundValuesParser.set, value).get)
            case _: MapType => codec.parse(boundValuesParser.parse(boundValuesParser.map, value).get)
            case _: UserDefinedType => codec.parse(boundValuesParser.parse(boundValuesParser.udt, value).get)
            case _: TupleType => codec.parse(boundValuesParser.parse(boundValuesParser.tuple, value).get)
            case _ => throw new InterpreterException(s"Cannot parse data of type : ${dataType.toString}")
          }
        }
    }.asInstanceOf[List[AnyRef]]

    ps.bind(convertedValues.toArray: _*)
  }