4paradigm / 4paradigm/OpenMLDB

ConstNode GetAsXXXX methods refactor

Open
#580 4 comments 0 reactions 1 assignee Claimed by @jingchen2222 View on GitHub
enhancement
Dominant language
C++
Stars
1.7k
Forks
331
Avg merge
12d 12h
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

This issue is going to to Refactor ConstNode's GetAsXXXX methods, e.g. `GetAsString()`, `GetAsDouble` etc, since it is hard to know if these GetAsXXXX methods go well or not. So we have to re-design the methods as follows:
```
bool GetAsInt(int* output);
bool GetAsString(std::string* str)
```

Also, we will support GetAsString for types like `kBool`, `kDate`, `kTimestamp`.
1. kBool: `true` -> `"true"`, kBool: `false` -> `"false"`
2. kTimestamp: `1590115420000` -> `"1590115420000L"`
3. kDate:
```
Date date(2020, 05, 22);
to_string(date.date_)
```
need to discuss what `kDate` string looks like. `yyyy-mm-dd` pattern string will be far more reasonable.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Research direction

Look for ConstNode class in the codebase, likely in a header file. Examine existing GetAsXXXX methods to understand their signatures and usage. The refactor changes return types to bool and uses output parameters. Also need to implement GetAsString for kBool, kDate, kTimestamp types, deciding on string format for kDate. Check for any existing tests for ConstNode to update.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.