(conf: DatasourceConf, table_name: str)
| 55 | |
| 56 | # get fields |
| 57 | def get_es_fields(conf: DatasourceConf, table_name: str): |
| 58 | es_client = get_es_connect(conf) |
| 59 | index_name = table_name |
| 60 | mapping = es_client.indices.get_mapping(index=index_name) |
| 61 | properties = mapping.get(index_name).get("mappings").get("properties") |
| 62 | res = [] |
| 63 | if properties is not None: |
| 64 | for field, config in properties.items(): |
| 65 | field_type = config.get("type") |
| 66 | desc = '' |
| 67 | if config.get("_meta"): |
| 68 | desc = config.get("_meta").get('description') |
| 69 | |
| 70 | if field_type: |
| 71 | res.append((field, field_type, desc)) |
| 72 | else: |
| 73 | # object、nested... |
| 74 | res.append((field, ','.join(list(config.keys())), desc)) |
| 75 | return res |
| 76 | |
| 77 | |
| 78 | # def get_es_data(conf: DatasourceConf, sql: str, table_name: str): |
no test coverage detected