Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flash 411] use compatible new datetime/ date #224

Merged
merged 11 commits into from
Sep 16, 2019
Merged

Conversation

hanfei1991
Copy link
Member

No description provided.

@hanfei1991
Copy link
Member Author

/run-integration-tests

@hanfei1991
Copy link
Member Author

/run-integration-tests

1 similar comment
@hanfei1991
Copy link
Member Author

/run-integration-tests

Copy link
Contributor

@solotzg solotzg left a comment

Choose a reason for hiding this comment

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

Maybe you can try string_view and std::move.

return idx;
}

std::vector<String> parseDateFormat(String format)
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use const ref?

Copy link
Member Author

Choose a reason for hiding this comment

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

trimInPlace is defined as template<S> S& trimInPlace(S& str). If I pass a const ref, it will cause a compile error

dbms/src/Common/MyTime.cpp Outdated Show resolved Hide resolved
dbms/src/DataTypes/DataTypeFactory.cpp Show resolved Hide resolved

using FunctionToYYYYMM = FunctionDateOrDateTimeToSomething<DataTypeUInt32, ToYYYYMMImpl>;
using FunctionToYYYYMMDD = FunctionDateOrDateTimeToSomething<DataTypeUInt32, ToYYYYMMDDImpl>;
using FunctionToYYYYMMDDhhmmss = FunctionDateOrDateTimeToSomething<DataTypeUInt64, ToYYYYMMDDhhmmssImpl>;

using FunctionAddSeconds = FunctionDateOrDateTimeAddInterval<AddSecondsImpl>;
using FunctionAddMinutes = FunctionDateOrDateTimeAddInterval<AddMinutesImpl>;
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like all the existing date/datetime udfs do not work for new datetime/date?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

{

const char * s = buf.position();
if (s + 19 <= buf.buffer().end())
Copy link
Contributor

Choose a reason for hiding this comment

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

where is the pessimistic path?

dbms/src/IO/ReadHelpers.h Show resolved Hide resolved
UInt64 ymd = ((UInt64)values.year * 13 + values.month) << 5 | values.day_of_month;
UInt64 hms = (UInt64)hour << 12 | minute << 6 | second;
copy = (ymd << 17 | hms) << 24;
auto plain_text = orig.safeGet<String>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why get String from the orig filed? The orig field is the internal representation in TiFlash, and TiFlash does not use String to represent the date/datetime

Copy link
Member Author

Choose a reason for hiding this comment

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

It's only used by test. User insert datetime/date by string literal

@@ -43,14 +43,14 @@ using DB::Timestamp;
M(Float, 4, Float, Float32, false) \
M(Double, 5, Float, Float64, false) \
M(Null, 6, Nil, Nothing, false) \
M(Timestamp, 7, Int, DateTime, false) \
M(Timestamp, 7, Int, MyDateTime, false) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why timestamp is mapped to MyDateTime instead of MyTimestamp?

Copy link
Member Author

Choose a reason for hiding this comment

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

Has not implemented

@windtalker
Copy link
Contributor

Does this pr support session level timezone? And in Mysql/TiDB only the values of the Timestamp data type is affected by time zone, does TiFlash follow this principle?

String toString() const;
};

struct MyDate : public MyTimeBase
Copy link
Contributor

Choose a reason for hiding this comment

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

MyDate inherits from MyTimeBase may introduce too much overhead. Can we use a lightweight class?

Copy link
Member Author

Choose a reason for hiding this comment

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

TiDB use uint64 to store date type, we can optimize it in the future.

@hanfei1991
Copy link
Member Author

@windtalker I will support timestamp and timezone in next pr

@hanfei1991
Copy link
Member Author

/rebuild

@hanfei1991
Copy link
Member Author

/run-integration-tests tiflash=hanfei-new-datetime

1 similar comment
@hanfei1991
Copy link
Member Author

/run-integration-tests tiflash=hanfei-new-datetime

@hanfei1991
Copy link
Member Author

@windtalker PTAL again

@hanfei1991 hanfei1991 changed the title [flash 441] use compatible new datetime/ date [flash 411] use compatible new datetime/ date Sep 12, 2019
MyDate,
MyDateTime,
MyTimeStamp,
MyTime
Copy link
Contributor

Choose a reason for hiding this comment

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

MyTime is mapping TypeDuration in MyTimeType enum? Better to use the same suffix, MyTime => MyDuration or TypeDuration => TypeTime

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to keep consistent with MySQL Grammar

DECLARE_DICT_GET_TRAITS(UInt32, DataTypeDate)
DECLARE_DICT_GET_TRAITS(Int64, DataTypeDateTime)
DECLARE_DICT_GET_TRAITS(UInt16, DataTypeDate)
DECLARE_DICT_GET_TRAITS(UInt32, DataTypeDateTime)
Copy link
Contributor

Choose a reason for hiding this comment

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

why new type is not declared here?

Copy link
Member Author

Choose a reason for hiding this comment

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

FunctionsExternalDictionaries.h has no relation with our own logic.

@hanfei1991
Copy link
Member Author

/run-integration-tests tiflash=hanfei-new-datetime

@@ -17,96 +18,19 @@ using DB::Field;
template <TP tp, typename = void>
struct DatumOp
{
static void unflatten(const Field &, std::optional<Field> &) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't remove unflattern/flattern methods, we are using them to deal with sign mismatch of Enum type between TiDB and TiFlash.

Just remove the unnecessary specialization version of Datum for Date/DateTime.

@hanfei1991
Copy link
Member Author

/run-integration-tests tiflash=hanfei-new-datetime

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@hanfei1991
Copy link
Member Author

/run-integration-tests tiflash=hanfei-new-datetime

@hanfei1991 hanfei1991 merged commit d8c631f into master Sep 16, 2019
@hanfei1991 hanfei1991 deleted the hanfei-datetime branch September 16, 2019 11:02
JaySon-Huang added a commit to JaySon-Huang/tiflash that referenced this pull request Aug 2, 2024
Signed-off-by: Wish <breezewish@outlook.com>
Co-authored-by: JaySon <tshent@qq.com>
JaySon-Huang added a commit that referenced this pull request Aug 6, 2024
Signed-off-by: Wish <breezewish@outlook.com>
Co-authored-by: JaySon <tshent@qq.com>
Lloyd-Pottiger pushed a commit to Lloyd-Pottiger/tiflash that referenced this pull request Aug 26, 2024
Signed-off-by: Wish <breezewish@outlook.com>
Co-authored-by: JaySon <tshent@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants