from .impl import DefaultImpl
class HiveImpl(DefaultImpl):
__dialect__ = 'hive'
I simply want to be able to execute raw SQL against a Hive instance (no ORM implementation needed) and I was hoping to use Alembic to manage the minimum upgrade/downgrade functionality. Are there any simple edits I can make to the Alembic source code to allow me to achieve this goal?
Thanks,
Alexander
> an email to sqlalchemy-alembic+unsub...@googlegroups.com
> <mailto:sqlalchemy-alembic+unsub...@googlegroups.com>.
> > an email to sqlalchemy-alembic+unsub...@googlegroups.com
> <javascript:>
> > <mailto:sqlalchemy-alembic+unsub...@googlegroups.com
> <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy-alembic+unsub...@googlegroups.com
> <mailto:sqlalchemy-alembic+unsub...@googlegroups.com>.
> > > an email to sqlalchemy-alembic+unsub...@googlegroups.com
> <javascript:>
> > <javascript:>
> > > <mailto:sqlalchemy-alembic+unsub...@googlegroups.com
> <javascript:>
> > <javascript:>>.
> > > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>
> > <https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>>.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "sqlalchemy-alembic" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to sqlalchemy-alembic+unsub...@googlegroups.com
> <javascript:>
> > <mailto:sqlalchemy-alembic+unsub...@googlegroups.com
> <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy-alembic+unsub...@googlegroups.com
> <mailto:sqlalchemy-alembic+unsub...@googlegroups.com>.
Just discovered this post when trying to do exact same thing (besides planning to support one more dialect).> Anywhere in your hive dialect, simply put the above code that you have (using the correct imports of course).Does it mean it must introduce dependency to alembic (since it uses alembic.ddl.impl.DefaultImpl) in a package (.e.g, pyHive) that supports sqlalchemy interfaces?
If not, is there any guidance to support this at alembic level in a plug-gable way? E.g., declare a HiveImpl class in `env.py` of a project uses alembic?
--You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alem...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy-alembic/59b308d9-7a9f-4038-bb52-f578c2c9cb69%40googlegroups.com.
Mike,Thanks for the pointers. I've figured out the programming part and discovers more things when integrating PyHive:1. It requires the table alembic_version to be transactional so that it can do Update/Delete when upgrade/downgrade. which is challege for Hive3 which has limited ACID support. Since I could not figure out a way to program a transactional table via SQLAlechemy API (see https://github.com/dropbox/PyHive/issues/314), it ended up a decoration to patch sqlalchemy.schema.CreateTable by appending table properties.
2. PyHive doesn't fully support Update/Delete for Hive/Presto yet. it's easy to patch PyHive but the key problem is it doesn't support transactional DDL like rollback in Hive3.Although I've managed to get `alembic upgrade` and `alembic downgrade` to work on Hive 3, it's still not a fully transactional experience (e.g., changed schema sccessfully but failed to update table alembic_version).
I wonder if there's any design direction in Alembic to allowing storing the version table `alembic_version` in another db when dealing with non-RDBMS SQL engine (Hive/Presto). e.g., supporting a postgres db to store table alembic while delivering the actual changes to Hive. I had a PoC to using multi-db template to manage the table `alembic_version` in a RDBMS while denying any operation on table `alembic_version` in Hive/Presto. it works now but does it sound right?
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy-alembic/d0623681577b433554974720744cb5dd835dd126.camel%40us.ibm.com.Attachments:
- smime.p7s
According to Apache Hive, Update/Delete can only be performed on tables that supports ACID. see https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Update> this is a database that can change schema structures but not insert/update/delete rows? is there some kind of SQL layer that has to be in use that isn't there when you create structures?Yes! Basically it separate data store and data model so that you can update table schema as metadata while the actual data can be loaded/streamed into external data store w/o SQL interface.> that wouldn't be very easy but also it would be way better to store the version info in the target DB itself.totally understand this. I see this design as advantage as well just like other schema management tool like sqitch. I'm just looking for possiblilities since I've seen it uses the same connection to execute schema changes and versioning change in a migration context.> I don't know anything about Hive/Presto, but they *are* databases so I'd assume you can put data in themYes to Hive, when using PyHive, it just needs to fix https://github.com/dropbox/PyHive/issues/315
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy-alembic/8414ea00ba7a587499b71457649aa7717661d82c.camel%40us.ibm.com.
oh, that issue is talking about rowcount. Alembic does not need rowcount to function correctly. I see that Alembic is doing this now, however there is a dialect-level flag called "supports_sane_rowcount", if this were False, Alembic should be checking this and skipping that particular check.
is the "rowcount" check the only issue here? this part can be changed on the Alembic side.
CREATE TABLE hello_acid (key int, value int) STORED AS ORC TBLPROPERTIES ('transactional'='true');
On Wed, 2020-02-26 at 11:07 -0500, Mike Bayer wrote:oh, that issue is talking about rowcount. Alembic does not need rowcount to function correctly. I see that Alembic is doing this now, however there is a dialect-level flag called "supports_sane_rowcount", if this were False, Alembic should be checking this and skipping that particular check.I see. it would be great if Alembic will respect the "support_sane_rowcount" specified in a SQLAlchemy dialect when updating/deleting revision. If this is a suggested design, I can patch it via a PR.
According to specific dialect, it just need to use this option instead of returning "-1". I can document this in the issue https://github.com/dropbox/PyHive/issues/315
is the "rowcount" check the only issue here? this part can be changed on the Alembic side.Besides the above issue, I want to get input on https://github.com/dropbox/PyHive/issues/314 as well. How could I use SQLAlchemy API to create table like what this sql does:CREATE TABLE hello_acid (key int, value int) STORED AS ORC TBLPROPERTIES ('transactional'='true');I've no idea how to make `STORED AS and TBLPROPERTIES` part for a Hive table. Now I just use SQLAlchemy compiler to append them for CreateTable.
--You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alem...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy-alembic/ab42854af49a98c83fd3693c92dbd9ad5c59b9df.camel%40us.ibm.com.