| |
- setbit(target_arg, target_bit_arg, target_value_arg)
- DESCRIPTION:
Function sets the value of the bit specified by target_bit_arg to the value
of target_value_arg in the target_arg byte expression.
PARAMETERS:
target_arg:
Required Argument.
Specifies a ColumnExpression of an integer or byte column or a numeric or byte
literal value.
If the argument is NULL, the function returns NULL.
Format of a ColumnExpression of a column: '<dataframe>.<dataframe_column>.expression'.
Supported SQL column types: BYTEINT, SMALLINT, INTEGER, BIGINT, and VARBYTE(n)
target_bit_arg:
Required Argument.
Specifies a ColumnExpression of an integer column or an integer literal.
Following rules apply to the values of target_bit_arg:
* The range of input values can vary from 0 (bit 0 is the least significant
bit) to the (sizeof(target_arg) - 1).
* If target_bit_arg is negative or out-of-range (meaning that it exceeds the size
of target_arg), an error is returned.
* If the argument is NULL, the function returns NULL.
Format of a ColumnExpression of a column: '<dataframe>.<dataframe_column>.expression'.
Supported SQL column types: INTEGER
target_value_arg:
Optional Argument.
Specifies a ColumnExpression of an integer column or an integer literal representing
a binary bit value, 0 or 1, to be set within the target_arg expression.
If target_value_arg is not specified, the default is 1.
If the argument is NULL, the function returns NULL.
Format of a ColumnExpression of a column: '<dataframe>.<dataframe_column>.expression'.
Supported SQL column types: INTEGER
NOTE:
Function accepts positional arguments only.
EXAMPLES:
# Load the data to run the example.
>>> load_example_data("dataframe", "bytes_table")
>>>
# Create a DataFrame on 'bytes_table' table.
>>> bytes_table = DataFrame("bytes_table")
>>> bytes_table
byte_col varbyte_col blob_col
id_col
2 b'61' b'616263643132' b'6162636431323233'
1 b'62' b'62717765' b'3331363136323633'
0 b'63' b'627A7863' b'3330363136323633'
>>>
# Example set the fourth bit from the values in "varbyte_col" column with "1".
# Import func from sqlalchemy to execute setbit function.
>>> from sqlalchemy import func
# Note: Function name case does not matter. We can use the function name in
# lower case, upper case or mixed case.
>>> df = bytes_table.assign(setbit_varbyte_= func.setbit(bytes_table.varbyte_col.expression, 3))
>>> print(df)
byte_col varbyte_col blob_col setbit_varbyte_
id_col
0 b'63' b'627A7863' b'3330363136323633' b'627A786B'
2 b'61' b'616263643132' b'6162636431323233' b'61626364313A'
1 b'62' b'62717765' b'3331363136323633' b'6271776D'
>>>
|