Skip to content

[function](date function)add new date function 'last_day'#13400

Closed
lsy3993 wants to merge 30 commits intoapache:masterfrom
lsy3993:lsy_last_day
Closed

[function](date function)add new date function 'last_day'#13400
lsy3993 wants to merge 30 commits intoapache:masterfrom
lsy3993:lsy_last_day

Conversation

@lsy3993
Copy link
Contributor

@lsy3993 lsy3993 commented Oct 16, 2022

Proposed changes

Issue Number: close #13139

Problem summary

Describe your changes.

Checklist(Required)

  1. Does it affect the original behavior:
    • Yes
    • No
    • I don't know
  2. Has unit tests been added:
    • Yes
    • No
    • No Need
  3. Has document been added or modified:
    • Yes
    • No
    • No Need
  4. Does it need to update dependencies:
    • Yes
    • No
  5. Are there any changes that cannot be rolled back:
    • Yes (If Yes, please explain WHY)
    • No

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@github-actions github-actions bot added area/sql/function Issues or PRs related to the SQL functions area/vectorization kind/docs Categorizes issue or PR as related to documentation. kind/test labels Oct 16, 2022

DateTimeValue ts_value = DateTimeValue::from_datetime_val(ts_val);

bool is_leap_year = (ts_value.year() % 400 == 0) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use doris::is_leap(year)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as get_last_month_day?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

static int get_last_month_day(int year, int month) {
bool is_leap_year = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use doris::is_leap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

qt_sql """ select seconds_sub(test_time2,1) result from ${tableName}; """

// test last_day
sql """ SET enable_vectorized_engine = TRUE; """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add a case for row-based engine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


String get_name() const override { return name; }

bool use_default_implementation_for_nulls() const override { return true; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_default_implementation_for_constants also need to override and set to true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// input DateTime and Date, return Date
// input DateTimeV2 and DateV2, return DateV2
DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
if constexpr (std::is_same_v<DateType, DataTypeDateTime>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use or to collapse these two conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

DataTypes get_variadic_argument_types_impl() const override {
if constexpr (std::is_same_v<DateType, DataTypeDateTime>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataTypeDate is also possible as input argument

} else {
// neither DateTime nor DateTimeV2/DateV2, return null
if constexpr (std::is_same_v<DateType, DataTypeDateTime>) {
res_column = ColumnInt64::create(input_rows_count);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check seems to have been done at the above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, I delete the 'else'

zxealous and others added 22 commits October 18, 2022 17:45
…mn (#13365)

We should prevent insert while value overflow.

1. create table:
`CREATE TABLE test_array_load_test_array_int_insert_db.test_array_load_test_array_int_insert_tb ( k1 int NULL, k2 array<int> NULL ) DUPLICATE KEY(k1) DISTRIBUTED BY HASH(k1) BUCKETS 5`

2. try insert data less than INT_MIN.
`insert into test_array_load_test_array_int_insert_tb values (1005, [-2147483649])`

Before this pr, the insert will success, but the value it not correct.
Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
Doris do not support explicitly cast NULL_TYPE to ANY type .

```
mysql> select cast(NULL as int);
ERROR 1105 (HY000): errCode = 2, detailMessage = Invalid type cast of NULL from NULL_TYPE to INT
```

So we should also forbid user from casting NULL_TYPE to ARRAY type.

This commit will produce the following effect:

```
mysql> select cast(NULL as array<int>);
ERROR 1105 (HY000): errCode = 2, detailMessage = Invalid type cast of NULL from NULL_TYPE to ARRAY<INT(11)>
```
…olumn (#13345)

1. this pr is used to update the json load docs for  import data to array column.
when we use json to import data to array column,  the Rapidjson will cause precision problems. 
so we update the json-load docs to specify how to avoid these problems.

Issue Number: #7570
Co-authored-by: hucheng01 <hucheng01@baidu.com>
…f en docs. (#13391)

Co-authored-by: smallhibiscus <8449081280@qq.com>
…table for most cases (#13370)

It is frustrated that a long running job fails due to small timeout. Actually, users
do not expect a timeout for a log running job.
Previously, bthread_getspecific was called every time bthread local was used. In the test at #10823, it was found that frequent calls to bthread_getspecific had performance problems.

So a cache is implemented on pthread local based on the btls key, but the btls key cannot correctly sense bthread switching.

So, based on bthread_self to get the bthread id to implement the cache.
support `group_bitmap_xor` agg function
…ework (#13354)

1. Refactor the file reader creation in FileFactory, for simplicity.
    Previously, FileFactory had too many `create_file_reader` interfaces.
    Now unified into two categories: the interface used by the previous BrokerScanNode,
    and the interface used by the new FileScanNode.
    And separate the creation methods of readers that read `StreamLoadPipe` and other readers that read files.

2. Modify the StreamLoadPlanner on FE side to support using ExternalFileScanNode

3. Now for generic reader, the file reader will be created inside the reader, not passed from the outside.

4. Add some test cases for csv stream load, the behavior is same as the old broker scanner.
…ate/datetime type (#13407)

This pr is used to expand the supported data type for array_min/array_max function.
Before the change , the array_min/array_max function can't support the date/datetime type.
After the change, array_min/array_max function can support the date/datetime type.
Co-authored-by: hucheng01 <hucheng01@baidu.com>
…e, CHAR and VARCHAR type (#13311)

1. enable varchar/char type set min/max value.
    take first 8 chars as long, and convert to double.
2. fix bug when set min/max value for date and datav2
…13195)

# Proposed changes

This PR fixed lots of issues when building from source on macOS with Apple M1 chip.

## ATTENTION

The job for supporting macOS with Apple M1 chip is too big and there are lots of unresolved issues during runtime:
1. Some errors with memory tracker occur when BE (RELEASE) starts.
2. Some UT cases fail.
...

Temporarily, the following changes are made on macOS to start BE successfully.
1. Disable memory tracker.
2. Use tcmalloc instead of jemalloc.

This PR kicks off the job. Guys who are interested in this job can continue to fix these runtime issues.

## Use case

```shell
./build.sh -j 8 --be --clean

cd output/be/bin
ulimit -n 60000
./start_be.sh --daemon
```

## Something else

It takes around _**10+**_ minutes to build BE (with prebuilt third-parties) on macOS with M1 chip. We will improve the  development experience on macOS greatly when we finish the adaptation job.
…13404)

Use apache orc to read orc file, and convert ColumnVectorBatch to doris block.
@lsy3993 lsy3993 closed this by deleting the head repository Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sql/function Issues or PRs related to the SQL functions area/vectorization kind/docs Categorizes issue or PR as related to documentation. kind/test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Add new builtin function of the last day of month