Skip to content

Instantly share code, notes, and snippets.

@Stiivi
Last active December 16, 2015 05:39
Show Gist options
  • Save Stiivi/5385722 to your computer and use it in GitHub Desktop.
Save Stiivi/5385722 to your computer and use it in GitHub Desktop.
Type dispatch in Python
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