4paradigm / 4paradigm/OpenMLDB

ddl_parser: add yaml test & support json schema to make test easier

Aperta
#931 0 commenti 0 reazioni 1 assegnatario Rivendicata da @vagetablechicken Vedi su GitHub
call-for-contributions
Lingua principale
C++
Stelle
1.7k
Fork
331
Merge medio
12g 12h
PR unite (30g)
1

Descrizione

When the user reports an `ExtractIndexes`(DDLParser) error, the user usually provides a sql with a schema json str.
If we want to run the test, we need to hard code in ddl_parser_test.cc. And the json schema should be converted to a vector or a string manually(`AddTableToDB` doesn't support json schema). It's not good.

We should support the json schema. A new `AddTableToDB`. The json schema input is like:
```
{
"tableInfo":{
"t1":[
{
"name":"rank",
"type":"string"
},
...
],
"t2":[
{
"name":"c1",
"type":"string"
},
...
]
}
}
```

Then if we support reading test cases from yaml files, we can avoid adding every test to the source code. Just add it to the yaml files.
For example, the yaml file could be:
```
extract_indexes_cases:
- id: xx
sql: ...
schema: ...
result: ...
- id: yy
```
or you can use the json style, like:
```
{ "table_info": {"t1": [...], "t2": [...], ...}, "sql": "..." }
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Look at ddl_parser_test.cc to understand the current test structure and the AddTableToDB function. The task is to modify AddTableToDB to accept a JSON schema string as described, and to add support for reading test cases from YAML files. Start by examining how the existing tests are structured and where the schema data is currently hardcoded. The goal is to create a new test harness that can load cases from YAML, parse the JSON schema, and run the ExtractIndexes tests.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, json, yaml
Ambito
databases, testing
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.