Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WIP: [Issue-36] Add DateTime64 data type. #38

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

Closed
wants to merge 4 commits into from

Conversation

tshev
Copy link
Contributor

@tshev tshev commented Apr 23, 2020

Going to add tests, and we are good to go.

@tshev tshev force-pushed the tshev/Issue-36-Add-DateTime64 branch from 2051808 to fb3170f Compare April 23, 2020 17:20
@tshev tshev force-pushed the tshev/Issue-36-Add-DateTime64 branch from fc72ee7 to 3c57c4b Compare April 23, 2020 17:24
@@ -113,4 +113,69 @@ ItemView ColumnDateTime::GetItem(size_t index) const {
return data_->GetItem(index);
}


ColumnDateTime64::ColumnDateTime64()
: Column(Type::CreateDateTime64(3ul))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we shouldn't provide a default constructor at all or come up with a different default precision. I will be happy to get feedback regarding this line.

}


Int128 ColumnDateTime64::At(size_t n) const {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I Decided to use Int128 because ColumnDecimal deals with this type. Poco supports https://pocoproject.org/docs/Poco.DateTime.html, but DateTime64 in Clickhouse has a higher resolution than in Poco.

@tshev tshev changed the title WIP: [Issue-36] Add support of DateTime64 WIP: [Issue-36] Add DateTime64 data type. Apr 23, 2020
Copy link
Contributor

@Enmk Enmk left a comment

Choose a reason for hiding this comment

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

Great start!

  • Please add unit-tests!
  • Please fix other issues.

size_t precision = col->Type()->As<DateTime64Type>()->GetPrecision();
auto result = std::make_shared<ColumnDateTime64>(precision); // TODO FIXME

result->data_->Append(col);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why appending when you can swap?

ColumnDateTime64(size_t);

/// Appends one element to the end of column.
void Append(const Int128& value);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather use Int64 here, since it is a bit misleading to put 128-bit int into DateTime64 column

class ColumnDateTime64 : public Column {
public:
ColumnDateTime64();
ColumnDateTime64(size_t);
Copy link
Contributor

Choose a reason for hiding this comment

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

that should be explicit

/** */
class ColumnDateTime64 : public Column {
public:
ColumnDateTime64();
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think that having a default precision here is a good thing, can you remove it?

void Append(const std::string& value);

/// Returns element at given row number.
Int128 At(size_t n) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it makes sense to use Int64 here too.


/// Returns element at given row number.
Int128 At(size_t n) const;

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add method GetPrecision() const

@@ -26,6 +26,7 @@ class Type {
String,
FixedString,
DateTime,
DateTime64,
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO that could break some implicit user assumptions, it is better to add new enum value to the end of the list.


ColumnRef ColumnDateTime64::Slice(size_t begin, size_t len) {
auto col = data_->Slice(begin, len)->As<ColumnDecimal>();
size_t precision = col->Type()->As<DateTime64Type>()->GetPrecision();
Copy link
Contributor

@Enmk Enmk Apr 23, 2020

Choose a reason for hiding this comment

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

that would blow up terribly, do you mean col->Type()->As<DecimalType>()->GetPrecision()? Also please add following to the DecimalType:

inline size_t GetPrecision() const { return precision_; }

@@ -144,6 +147,18 @@ class DecimalType : public Type {
const size_t precision_, scale_;
};

class DateTime64Type: public Type {
public:
DateTime64Type(size_t precision);
Copy link
Contributor

Choose a reason for hiding this comment

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

please make it explicit

@asierguti
Copy link

What's the status of this PR? I would like to use this feature. Is there any way I could contribute or help anyway?

@Enmk Enmk mentioned this pull request Sep 3, 2020
@traceon traceon closed this in #50 Sep 11, 2020
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.

3 participants