Returns a prased output based on type describe output. data_type is string that should look like this: "bigint" or like this: "array >" In the first case, this method would return:
(self, data_type)
| 267 | return 'SHOW TABLES' |
| 268 | |
| 269 | def parse_col_desc(self, data_type): |
| 270 | ''' Returns a prased output based on type describe output. |
| 271 | data_type is string that should look like this: |
| 272 | "bigint" |
| 273 | or like this: |
| 274 | "array<struct< |
| 275 | field_51:int, |
| 276 | field_52:bigint, |
| 277 | field_53:int, |
| 278 | field_54:boolean |
| 279 | >>" |
| 280 | In the first case, this method would return: 'bigint' |
| 281 | In the second case, it would return |
| 282 | ['array', |
| 283 | ['struct', |
| 284 | ['field_51', 'int'], |
| 285 | ['field_52', 'bigint'], |
| 286 | ['field_53', 'int'], |
| 287 | ['field_54', 'boolean']]] |
| 288 | This output is used to create the appropriate columns by self.create_column(). |
| 289 | ''' |
| 290 | |
| 291 | COMMA, LPAR, RPAR, COLON, LBRA, RBRA = map(Suppress, ",<>:()") |
| 292 | |
| 293 | t_bigint = Literal('bigint') |
| 294 | t_int = Literal('int') |
| 295 | t_integer = Literal('integer') |
| 296 | t_smallint = Literal('smallint') |
| 297 | t_tinyint = Literal('tinyint') |
| 298 | t_boolean = Literal('boolean') |
| 299 | t_string = Literal('string') |
| 300 | t_timestamp = Literal('timestamp') |
| 301 | t_timestamp_without_time_zone = Literal('timestamp without time zone') |
| 302 | t_float = Literal('float') |
| 303 | t_double = Literal('double') |
| 304 | t_real = Literal('real') |
| 305 | t_double_precision = Literal('double precision') |
| 306 | |
| 307 | t_decimal = Group(Literal('decimal') + LBRA + Word(nums) + COMMA + Word(nums) + RBRA) |
| 308 | t_numeric = Group(Literal('numeric') + LBRA + Word(nums) + COMMA + Word(nums) + RBRA) |
| 309 | t_char = Group(Literal('char') + LBRA + Word(nums) + RBRA) |
| 310 | t_character = Group(Literal('character') + LBRA + Word(nums) + RBRA) |
| 311 | t_varchar = (Group(Literal('varchar') + LBRA + Word(nums) + RBRA) | |
| 312 | Literal('varchar')) |
| 313 | t_character_varying = Group(Literal('character varying') + LBRA + Word(nums) + RBRA) |
| 314 | |
| 315 | t_struct = Forward() |
| 316 | t_array = Forward() |
| 317 | t_map = Forward() |
| 318 | |
| 319 | complex_type = (t_struct | t_array | t_map) |
| 320 | |
| 321 | any_type = ( |
| 322 | complex_type | |
| 323 | t_bigint | |
| 324 | t_int | |
| 325 | t_integer | |
| 326 | t_smallint | |
no test coverage detected