MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getColumnDefinition

Function getColumnDefinition

src/Core/MySQL/PacketsProtocolText.cpp:158–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158ColumnDefinition getColumnDefinition(const String & column_name, const DataTypePtr & data_type)
159{
160 ColumnType column_type = {};
161 CharacterSet charset = CharacterSet::binary;
162 int flags = 0;
163 uint8_t decimals = 0;
164 DataTypePtr normalized_data_type = removeLowCardinalityAndNullable(data_type);
165 TypeIndex type_index = normalized_data_type->getTypeId();
166 switch (type_index)
167 {
168 case TypeIndex::UInt8:
169 column_type = ColumnType::MYSQL_TYPE_TINY;
170 flags = ColumnDefinitionFlags::BINARY_FLAG | ColumnDefinitionFlags::UNSIGNED_FLAG;
171 break;
172 case TypeIndex::UInt16:
173 column_type = ColumnType::MYSQL_TYPE_SHORT;
174 flags = ColumnDefinitionFlags::BINARY_FLAG | ColumnDefinitionFlags::UNSIGNED_FLAG;
175 break;
176 case TypeIndex::UInt32:
177 column_type = ColumnType::MYSQL_TYPE_LONG;
178 flags = ColumnDefinitionFlags::BINARY_FLAG | ColumnDefinitionFlags::UNSIGNED_FLAG;
179 break;
180 case TypeIndex::UInt64:
181 column_type = ColumnType::MYSQL_TYPE_LONGLONG;
182 flags = ColumnDefinitionFlags::BINARY_FLAG | ColumnDefinitionFlags::UNSIGNED_FLAG;
183 break;
184 case TypeIndex::Int8:
185 column_type = ColumnType::MYSQL_TYPE_TINY;
186 flags = ColumnDefinitionFlags::BINARY_FLAG;
187 break;
188 case TypeIndex::Int16:
189 column_type = ColumnType::MYSQL_TYPE_SHORT;
190 flags = ColumnDefinitionFlags::BINARY_FLAG;
191 break;
192 case TypeIndex::Int32:
193 column_type = ColumnType::MYSQL_TYPE_LONG;
194 flags = ColumnDefinitionFlags::BINARY_FLAG;
195 break;
196 case TypeIndex::Int64:
197 column_type = ColumnType::MYSQL_TYPE_LONGLONG;
198 flags = ColumnDefinitionFlags::BINARY_FLAG;
199 break;
200 case TypeIndex::Float32:
201 column_type = ColumnType::MYSQL_TYPE_FLOAT;
202 flags = ColumnDefinitionFlags::BINARY_FLAG;
203 decimals = 31;
204 break;
205 case TypeIndex::Float64:
206 column_type = ColumnType::MYSQL_TYPE_DOUBLE;
207 flags = ColumnDefinitionFlags::BINARY_FLAG;
208 decimals = 31;
209 break;
210 case TypeIndex::Date:
211 case TypeIndex::Date32:
212 column_type = ColumnType::MYSQL_TYPE_DATE;
213 flags = ColumnDefinitionFlags::BINARY_FLAG;
214 break;
215 case TypeIndex::DateTime:

Callers 1

writePrefixMethod · 0.85

Calls 5

ColumnDefinitionClass · 0.85
getPrecisionMethod · 0.80
getTypeIdMethod · 0.45
getScaleMethod · 0.45

Tested by

no test coverage detected