Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Conversation

@erezsh
Copy link
Contributor

@erezsh erezsh commented May 11, 2022

No description provided.

@erezsh erezsh requested a review from sirupsen May 11, 2022 16:07
@erezsh
Copy link
Contributor Author

erezsh commented May 11, 2022

After we merge this, I will add the CLI options and parsing of relative time.

@erezsh erezsh requested a review from cfernhout May 11, 2022 16:07
Copy link
Contributor

@sirupsen sirupsen left a comment

Choose a reason for hiding this comment

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

Couple of comments, but basically looks good to me—you can merge this without me looking at it again if you prefer

yield Compare("<", self.key_column, str(self.end))
def __post_init__(self):
if not self.update_column and (self.min_time or self.max_time):
raise ValueError("Error: min_time/max_time feature requires to specify 'update_column'")
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻

if self.min_time is not None:
yield Compare("<=", Time(self.min_time), self.update_column)
if self.max_time is not None:
yield Compare("<", self.update_column, Time(self.max_time))
Copy link
Contributor

Choose a reason for hiding this comment

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

A Python question: Why is yield preferred here to just returning a list? Because it's annoying to merge the lists I'm assuming, versus adding generators together and then materializing them to a list like you're doing below? Kinda cool pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's just a cleaner syntax, saving me from creating a list, appending to it, and returning it.

if self.start_key is not None:
yield Compare("<=", str(self.start_key), self.key_column)
if self.end_key is not None:
yield Compare("<", self.key_column, str(self.end_key))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the key version will also benefit from a CLI arg 👍🏻 Thanks for changing its name and making it symmetric with time

Lots of people will probably instead of temporal just get the id of the last records when they did the last insertion, then do the check based on that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have -k. Do you mean something different?

}
""")
self.now = now = arrow.get(self.preql.now())
self.preql.add(now.shift(days=-50), "50 days ago")
Copy link
Contributor

Choose a reason for hiding this comment

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

When I try to run your tests, this line errors (and presumably the others will too):

CleanShot 2022-05-11 at 15 45 02@2x

Would love if preql gave some more useful output here 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't look related to preql in any way. What is Python.Framework? Never heard of it.

assert b.count == 5

assert not list(differ.diff_tables(a, a))
self.assertEqual( len( list(differ.diff_tables(a, b)) ), 1 )
Copy link
Contributor

Choose a reason for hiding this comment

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

Remember to run black(1), which'll probably complain about the spaces here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks

assert not list(differ.diff_tables(a, a))
self.assertEqual( len( list(differ.diff_tables(a, b)) ), 1 )

def test_offset(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

What about a test where the diff actually passes when you pass a range?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I do at the end of test_offset, unless you mean something else

@erezsh erezsh merged commit 4a14bdf into master May 12, 2022
nolar pushed a commit that referenced this pull request Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants