Last active
December 16, 2015 05:39
-
-
Save Stiivi/5385722 to your computer and use it in GitHub Desktop.
Type dispatch in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k = OperationKernel() | |
@k.operation("sql", "sql") | |
def append(l, r): | |
if l.engine == r.engine: | |
return "UNION ALL statement" | |
else: | |
raise RetryOperation(["sql", "rows"]) | |
@k.operation("sql", "rows") | |
def append(l, r): | |
return "chained iterators" | |
local = SQLTable("local") | |
remote = SQLTable("remote") | |
# Try to append two local tables | |
print k.append(local, local) | |
# Try to append local and a remote table | |
print k.append(local, remote) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment