Based on cqlengine.models.BaseModel._get_column.

        But to work with 'pk'
7640
def _get_column(cls, name):
        
        if name == 'pk':
            return cls._meta.get_field(cls._meta.pk.name)
        return cls._columns[name]
113151
def getcolkeyword(self, columnname, keyword):
        
        if isinstance(keyword, str):
            return self._getkeyword(columnname, keyword, -1)
        else:
            return self._getkeyword(columnname, '', keyword)
784482
private Schema getCustomColumnSchema(String columnName) {
    Schema schema = new Schema();
    String dataType = "string";
    schema.setColumnName(columnName);
    String elementDataType = "string";
    List<String> mapSymbols = null;
    JsonObject newDataType = this.convertDataType(columnName, dataType, elementDataType, mapSymbols);
    schema.setDataType(newDataType);
    schema.setWaterMark(false);
    schema.setPrimaryKey(0);
    schema.setLength(0);
    schema.setPrecision(0);
    schema.setScale(0);
    schema.setNullable(true);
    schema.setFormat(null);
    schema.setComment("Custom column");
    schema.setDefaultValue(null);
    schema.setUnique(false);
    return schema;
  }
1187201
private Object cqlColumnToObj(Cell col, CfDef cfDef) throws IOException
    {
        // standard
        Map<ByteBuffer,AbstractType> validators = getValidatorMap(cfDef);
        ByteBuffer cellName = col.name().toByteBuffer();
        if (validators.get(cellName) == null)
            return cassandraToObj(getDefaultMarshallers(cfDef).get(MarshallerType.DEFAULT_VALIDATOR), col.value());
        else
            return cassandraToObj(validators.get(cellName), col.value());
    }
637047
def parse_column_key(setting_string):
        
        if ':' in setting_string:
            # splits <column>:<key> into <column> and <key>
            column, key = setting_string.split(':', 1)
        else:
            # stores <column> and <value>=None
            column = setting_string
            key = None

        return column, key
858269
function Column(options, index, statementParameters, resultVersion)
{
  var name     = options.name;
  var nullable = options.nullable;
  var scale    = options.scale;
  var type     = options.type;

  /**
   * Returns the name of this column.
   *
   * @return {String}
   */
  this.getName = function()
  {
    return name;
  };

  /**
   * Returns the index of this column.
   *
   * @return {Number}
   */
  this.getIndex = function()
  {
    return index;
  };

  /**
   * Returns the id of this column.
   *
   * @return {Number}
   */
  this.getId = function()
  {
    // use the index as the id for now
    return index;
  };

  /**
   * Determines if this column is nullable.
   *
   * @returns {Boolean}
   */
  this.isNullable = function()
  {
    return nullable;
  };

  /**
   * Returns the scale associated with this column.
   *
   * @returns {Number}
   */
  this.getScale = function()
  {
    return scale;
  };

  /**
   * Returns the type associated with this column.
   *
   * @returns {String}
   */
  this.getType = function()
  {
    return type;
  };

  // add methods that make it easy to check if the column is of a specific type
  this.isString       = createFnIsColumnOfType(type, SqlTypes.isString, SqlTypes);
  this.isBinary       = createFnIsColumnOfType(type, SqlTypes.isBinary, SqlTypes);
  this.isNumber       = createFnIsColumnOfType(type, SqlTypes.isNumber, SqlTypes);
  this.isBoolean      = createFnIsColumnOfType(type, SqlTypes.isBoolean, SqlTypes);
  this.isDate         = createFnIsColumnOfType(type, SqlTypes.isDate, SqlTypes);
  this.isTime         = createFnIsColumnOfType(type, SqlTypes.isTime, SqlTypes);
  this.isTimestamp    = createFnIsColumnOfType(type, SqlTypes.isTimestamp, SqlTypes);
  this.isTimestampLtz = createFnIsColumnOfType(type, SqlTypes.isTimestampLtz, SqlTypes);
  this.isTimestampNtz = createFnIsColumnOfType(type, SqlTypes.isTimestampNtz, SqlTypes);
  this.isTimestampTz  = createFnIsColumnOfType(type, SqlTypes.isTimestampTz, SqlTypes);
  this.isVariant      = createFnIsColumnOfType(type, SqlTypes.isVariant, SqlTypes);
  this.isObject       = createFnIsColumnOfType(type, SqlTypes.isObject, SqlTypes);
  this.isArray        = createFnIsColumnOfType(type, SqlTypes.isArray, SqlTypes);

  var convert;
  var toString;
  var toValue;
  var format;

  if (this.isNumber())
  {
    convert  = convertRawNumber;
    toValue  = toValueFromNumber;
    toString = toStringFromNumber;
  }
  else if (this.isTime())
  {
    convert  = convertRawTime;
    toValue  = toValueFromTime;
    toString = toStringFromTime;
    format   = statementParameters['TIME_OUTPUT_FORMAT'];
  }
  else
  {
    toValue = noop;

    if (this.isBoolean())
    {
      convert  = convertRawBoolean;
      toString = toStringFromBoolean;
    }
    else if (this.isDate())
    {
      convert  = convertRawDate;
      toString = toStringFromDate;
      format   = statementParameters['DATE_OUTPUT_FORMAT'];
    }
    else if (this.isTimestamp())
    {
      if (this.isTimestampLtz())
      {
        convert  = convertRawTimestampLtz;
        toString = toStringFromTimestamp;
        format   = statementParameters['TIMESTAMP_LTZ_OUTPUT_FORMAT'];
      }
      else if (this.isTimestampNtz())
      {
        convert  = convertRawTimestampNtz;
        toString = toStringFromTimestamp;
        format   = statementParameters['TIMESTAMP_NTZ_OUTPUT_FORMAT'];
      }
      else if (this.isTimestampTz())
      {
        convert  = convertRawTimestampTz;
        toString = toStringFromTimestamp;
        format   = statementParameters['TIMESTAMP_TZ_OUTPUT_FORMAT'];
      }

      // if we don't have a type-specific timezone, use the default format
      if (!format)
      {
        format = statementParameters['TIMESTAMP_OUTPUT_FORMAT'];
      }
    }
    else if (this.isBinary())
    {
      convert = convertRawBinary;
      toString = toStringFromBinary;
      format = statementParameters['BINARY_OUTPUT_FORMAT'];
    }
    else if (this.isVariant())
    {
      convert  = convertRawVariant;
      toString = toStringFromVariant;
    }
    else
    {
      // column is of type string, so leave value as is
      convert  = noop;
      toString = toStringFromString;
    }
  }

  // create a private context to pass to the extract function
  var context =
  {
    convert             : convert,
    toValue             : toValue,
    toString            : toString,
    format              : format,
    resultVersion       : resultVersion,
    statementParameters : statementParameters
  };

  /**
   * Returns the value of this column in a row.
   *
   * @param {Object} row
   *
   * @returns {*}
   */
  this.getRowValue = function(row)
  {
    return extractFromRow.call(this, row, context, false);
  };

  /**
   * Returns the value of this in a row as a String.
   *
   * @param {Object} row
   *
   * @returns {String}
   */
  this.getRowValueAsString = function(row)
  {
    return extractFromRow.call(this, row, context, true);
  };
}
60786
private Object getFieldValueViaCQL(Object thriftColumnValue, Attribute attribute)
    {
        PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor((Field) attribute.getJavaMember());
        Object objValue;
        try
        {
            if (CassandraDataTranslator.isCassandraDataTypeClass(((AbstractAttribute) attribute).getBindableJavaType()))
            {
                objValue = CassandraDataTranslator.decompose(((AbstractAttribute) attribute).getBindableJavaType(),
                        thriftColumnValue, true);
                return objValue;
            }
            else
            {
                objValue = accessor.fromBytes(((AbstractAttribute) attribute).getBindableJavaType(),
                        (byte[]) thriftColumnValue);
                return objValue;
            }
        }
        catch (PropertyAccessException pae)
        {
            log.warn("Error while setting field{} value via CQL, Caused by: .", attribute.getName(), pae);
        }
        return null;
    }
153391
@Override
    public Object[] findIdsByColumn(String schemaName, String tableName, String pKeyName, String columnName,
            Object columnValue, Class entityClazz)
    {
        List<Object> rowKeys = new ArrayList<Object>();

        if (getCqlVersion().equalsIgnoreCase(CassandraConstants.CQL_VERSION_3_0))
        {
            rowKeys = findIdsByColumnUsingCql(schemaName, tableName, pKeyName, columnName, columnValue, entityClazz);
        }
        else
        {
            Selector selector = clientFactory.getSelector(pool);
            SlicePredicate slicePredicate = Selector.newColumnsPredicateAll(false, 10000);
            EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClazz);

            IndexClause ix = Selector.newIndexClause(Bytes.EMPTY, 10000, Selector.newIndexExpression(columnName
                    + Constants.JOIN_COLUMN_NAME_SEPARATOR + columnValue, IndexOperator.EQ,
                    Bytes.fromByteArray(PropertyAccessorHelper.getBytes(columnValue))));

            Map<Bytes, List<Column>> qResults = selector.getIndexedColumns(tableName, ix, slicePredicate,
                    getConsistencyLevel());

            // iterate through complete map and
            Iterator<Bytes> rowIter = qResults.keySet().iterator();
            while (rowIter.hasNext())
            {
                Bytes rowKey = rowIter.next();

                PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor((Field) metadata
                        .getIdAttribute().getJavaMember());
                Object value = accessor.fromBytes(metadata.getIdAttribute().getJavaType(), rowKey.toByteArray());

                rowKeys.add(value);
            }
        }
        if (rowKeys != null && !rowKeys.isEmpty())
        {
            return rowKeys.toArray(new Object[0]);
        }

        if (log.isInfoEnabled())
        {
            log.info("No row keys found, returning null.");
        }
        return null;
    }
800039
def iff(self, *args, **kwargs):
        """"""
        if len([x for x in kwargs.values() if x is None]):
            raise CQLEngineException("None values on iff are not allowed")

        clone = copy.deepcopy(self)
        for operator in args:
            if not isinstance(operator, ConditionalClause):
                raise QueryException('{0} is not a valid query operator'.format(operator))
            clone._conditional.append(operator)

        for arg, val in kwargs.items():
            if isinstance(val, Token):
                raise QueryException("Token() values are not valid in conditionals")

            col_name, col_op = self._parse_filter_arg(arg)
            try:
                column = self.model._get_column(col_name)
            except KeyError:
                raise QueryException("Can't resolve column name: '{0}'".format(col_name))

            if isinstance(val, BaseQueryFunction):
                query_val = val
            else:
                query_val = column.to_database(val)

            operator_class = BaseWhereOperator.get_operator(col_op or 'EQ')
            operator = operator_class()
            clone._conditional.append(WhereClause(column.db_field_name, operator, query_val))

        return clone
882917
def column(self):
        
        field = self.name

        model_field = get_model_field(self.schema, field)

        try:
            return getattr(self.model, model_field)
        except AttributeError:
            raise InvalidFilters("{} has no attribute {}".format(self.model.__name__, model_field))
736571
private ColumnInfo getColumn(TableInfo tableInfo, Attribute column, PropertyIndex indexedColumn,
            String[] orderByColumns)
    {
        ColumnInfo columnInfo = new ColumnInfo();

        if (column.getJavaType().isAnnotationPresent(OrderBy.class))
        {
            OrderBy order = (OrderBy) column.getJavaType().getAnnotation(OrderBy.class);
            orderByColumns = order.value().split("\\s*,\\s*");

        }
        columnInfo.setOrderBy(getOrderByColumn(orderByColumns, column));

        if (column.getJavaType().isEnum())
        {
            columnInfo.setType(String.class);
        }
        else
        {
            columnInfo.setType(column.getJavaType());
        }
        columnInfo.setColumnName(((AbstractAttribute) column).getJPAColumnName());
        if (indexedColumn != null && indexedColumn.getName() != null)
        {
            columnInfo.setIndexable(true);
            IndexInfo indexInfo = new IndexInfo(((AbstractAttribute) column).getJPAColumnName(), indexedColumn.getMax(),
                    indexedColumn.getMin(), indexedColumn.getIndexType(), indexedColumn.getName());
            tableInfo.addToIndexedColumnList(indexInfo);
            // Add more if required
        }

        return columnInfo;
    }
1002612
def iff(self, *args, **kwargs):
        """"""
        if len([x for x in kwargs.values() if x is None]):
            raise CQLEngineException("None values on iff are not allowed")

        clone = copy.deepcopy(self)
        for operator in args:
            if not isinstance(operator, TransactionClause):
                raise QueryException('{} is not a valid query operator'.format(operator))
            clone._transaction.append(operator)

        for col_name, val in kwargs.items():
            exists = False
            try:
                column = self.model._get_column(col_name)
            except KeyError:
                if col_name == 'pk__token':
                    if not isinstance(val, Token):
                        raise QueryException("Virtual column 'pk__token' may only be compared to Token() values")
                    column = columns._PartitionKeysToken(self.model)
                    quote_field = False
                else:
                    raise QueryException("Can't resolve column name: '{}'".format(col_name))

            if isinstance(val, Token):
                if col_name != 'pk__token':
                    raise QueryException("Token() values may only be compared to the 'pk__token' virtual column")
                partition_columns = column.partition_columns
                if len(partition_columns) != len(val.value):
                    raise QueryException(
                        'Token() received {} arguments but model has {} partition keys'.format(
                            len(val.value), len(partition_columns)))
                val.set_columns(partition_columns)

            if isinstance(val, BaseQueryFunction) or exists is True:
                query_val = val
            else:
                query_val = column.to_database(val)

            clone._transaction.append(TransactionClause(col_name, query_val))

        return clone
1077474
public <K> String get(final K key, Serializer<K> keySerializer) throws HectorException {
    ColumnQuery<K, String, String> q = createColumnQuery(keyspace, keySerializer, serializer, serializer);
    QueryResult<HColumn<String, String>> r = q.setKey(key).
        setName(COLUMN_NAME).
        setColumnFamily(CF_NAME).
        execute();
    HColumn<String, String> c = r.get();
    return c == null ? null : c.getValue();
  }
781248
private static void selectJsonColumn(CqlSession session) {

    Statement stmt =
        selectFrom("examples", "json_jackson_column")
            .all()
            .whereColumn("id")
            .in(literal(1), literal(2))
            .build();

    ResultSet rows = session.execute(stmt);

    for (Row row : rows) {
      int id = row.getInt("id");
      // retrieve the JSON payload and convert it to a User instance
      User user = row.get("json", User.class);
      // it is also possible to retrieve the raw JSON payload
      String json = row.getString("json");
      System.out.printf(
          "Retrieved row:%n id           %d%n user         %s%n user (raw)   %s%n%n",
          id, user, json);
    }
  }
564987
def get(self):
        
        if not hasattr(self, '_instance'):
            raise ImplementationError("Impossible to get the PK of an unbound field")
        if not hasattr(self._instance, '_pk'):
            raise DoesNotExist("The current object doesn't exists anymore")

        if not self._instance._pk:
            self.set(value=None)

        return self.normalize(self._instance._pk)
1249502
@Override
    public <E> List<E> getColumnsById(String schemaName, String tableName, String pKeyColumnName, String columnName,
            Object pKeyColumnValue, Class columnJavaType)
    {
        // fetch list ADDRESS_ID for given PERSON_ID
        QueryBuilder filterBuilder = new TermQueryBuilder(pKeyColumnName, pKeyColumnValue);

        SearchResponse response = txClient.prepareSearch(schemaName.toLowerCase()).setTypes(tableName)
                .setPostFilter(filterBuilder).addField(columnName).execute().actionGet();

        SearchHits hits = response.getHits();

        List columns = new ArrayList();
        for (SearchHit hit : hits.getHits())
        {
            Map<String, SearchHitField> fields = hit.getFields();
            columns.add(fields.get(columnName).getValue());
        }

        return columns;
    }
499526
public TColumn getPkColumn() {
		TColumn column = null;
		if (hasPkColumn()) {
			column = columns.get(pkIndex);
		}
		return column;
	}