Skip to main content
Edit this page

Client packets

valuenamedescription
0HelloClient handshake start
1QueryQuery request
2DataBlock with data
3CancelCancel query
4PingPing request
5TableStatusTable status request

The Data can be compressed.

Hello

For example, we are Go Client v1.10 that supports 54451 protocol version and want to connect to default database with default user and secret password.

fieldtypevaluedescription
client_nameString"Go Client"Client implementation name
version_majorUVarInt1Client major version
version_minorUVarInt10Client minor version
protocol_versionUVarInt54451TCP Protocol version
databaseString"default"Database name
usernameString"default"Username
passwordString"secret"Password

Protocol version

Protocol version is TCP protocol version of client.

Usually it is equal to the latest compatible server revision, but should not be confused with it.

Defaults

All values should be explicitly set, there are no defaults on server side. On client side, use "default" database, "default" username and "" (blank string) password as defaults.

Query

fieldtypevaluedescription
query_idString1ff-a123Query ID, can be UUIDv4
client_infoClientInfoSee typeData about client
settingsSettingsSee typeList of settings
secretStringsecretInter-server secret
stageUVarInt2Execute until query stage
compressionUVarInt0Disabled=0, enabled=1
bodyStringSELECT 1Query text

Client info

fieldtypedescription
query_kindbyteNone=0, Initial=1, Secondary=2
initial_userStringInitial user
initial_query_idStringInitial query id
initial_addressStringInitial address
initial_timeInt64Initial time
interfacebyteTCP=1, HTTP=2
os_userStringOS User
client_hostnameStringClient Hostname
client_nameStringClient Name
version_majorUVarIntClient major version
version_minorUVarIntClient minor version
protocol_versionUVarIntClient protocol version
quota_keyStringQuota key
distributed_depthUVarIntDistributed depth
version_patchUVarIntClient patch version
otelBoolTrace fields are present
trace_idFixedString(16)Trace ID
span_idFixedString(8)Span ID
trace_stateStringTracing state
trace_flagsByteTracing flags

Settings

fieldtypevaluedescription
keyStringsend_logs_levelKey of setting
valueStringtraceValue of setting
importantBooltrueCan be ignored or not

Encoded as list, blank key and value denotes end of list.

Stage

valuenamedescription
0FetchColumnsOnly fetch column types
1WithMergeableStateUntil mergeable state
2CompleteUntil full completeness (should be default)

Data

fieldtypedescription
infoBlockInfoEncoded block info
columnsUVarIntColumns count
rowsUVarIntRows count
columns[]ColumnColumns with data

Column

fieldtypevaluedescription
nameStringfooColumn name
typeStringDateTime64(9)Column type
databytes~Column data

Cancel

No packet body. Server should cancel query.

Ping

No packet body. Server should respond with pong.