Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    lkolla
    @lkolla
    thanks in advance
    Flavian Alexandru
    @alexflav23
    You could use phantom streams/
    and control the batches @lkolla
    @berkesokhan_twitter We do indeed support UDT in UDT.
    vonchav
    @voonchav_gitlab
    @alexflav23 Is it possible to run a raw query via Phantom? I wanted to test C* connection by running SELECT now() FROM system.local; Thanks.
    vonchav
    @voonchav_gitlab
    I can see there is a cql helper in the dsl package object. Just wondering if you can give an example how to wire things up and actually execute the cql? Thanks.
    vonchav
    @voonchav_gitlab
    I got it working :)
    3 replies
    Flavian Alexandru
    @alexflav23
    You call .future on it
    cql(“SELECT * from ….).future()
    vonchav
    @voonchav_gitlab
    thanks
    Arjun Karnwal
    @arjunkarnwal

    I have a question !!
    I can run the following cql in cassandra

    select * from activation_events where customerid = 18 and (campaignid, entityid) in ((91, 'X'),(94, 'Y'));

    How can I write the same in phantom dsl as

    select
      .where(_.customerId in ?)
      .and(_.campaignId in ?) // Here I need to have it as tuple for campaignId and entityid
      .consistencyLevel_=(ConsistencyLevel.ONE)
      .prepare()

    Please note that campaignid and entityid are seperate columns and not a tuple. As I said I am able to run the query using cql

    Flavian Alexandru
    @alexflav23
    there’s a syntax for this too in phantom
    I belive it was using ~
    Manuel Ramírez
    @DeaThrash

    Hello everyone! I'm currently moving from phantom-dsl 2.13.4 to 2.59.0. Back in 2.13.4 I used to have a Seq of insertQueries of different tables like this

    val inserts = Seq[InsertQuery[_ >: TableA with TableB with TableC <: Table[_ >: TableA with TableB with TableC, _ >: TableARecord with TableBRecord with TableCRecord], _ >: TableARecord with TableBRecord with TableCRecord <: Product, Unspecified, HNil]]

    And with that I was able to map them and execute each with the future() like this: (which looks like is part of the ExecutableStatement trait)

    inserts.map(insert => insert.consistencyLevel_=(LOCAL_QUORUM).future())

    But now that I'm working on 2.59.0 I'm not able to do the same. Is there a workaround provided by phantom? or should I split the list into single table statements?

    vonchav
    @voonchav_gitlab
    @alexflav23 I have a similar problem doing an IN clause with tuples. You mentioned ~. I searched Phantom docs as well as github and couldn't find an example. Could you be so kind to show an example of how to translate (campaignid, entityid) in ((91, 'X'),(94, 'Y')) in CQL into Phantom's DSL? Thanks a lot.
    Flavian Alexandru
    @alexflav23
    In is a list
    1 reply
    vonchav
    @voonchav_gitlab
    Hi, any plan for Phantom to be on Scala 2.13.3? I tried to upgrade my project to Scala 2.13.3 from 2.13.1 but I was getting some very weird compilation errors in my Phantom code - the rest of my project compiles okay. The main error is Auto-application to ( ) is deprecated. Supply the empty argument list ( ) explicitly to invoke method set on a line like this object Foo extends SetColumn[String] where I'm merely declaring a column in C*. The compiler seems to think I need to do SetColumn[String] ( ) but I'm only extending from SetColumn.
    I had a similar problem in code where I'm using .where(_.id.in( aList ) ). The 2.13.3 compiler complains the same error for the .in call. .in method take a list and a curried param as an implicit. I couldn't figure out why the compiler complains about Auto-application to ( ) is deprecated, unless it wants me to pass in the implicit explicitly.
    Flavian Alexandru
    @alexflav23
    You use ->?
    @voonchav_gitlab You can simply use a -> b syntax to construct tuples as well
    vonchav
    @voonchav_gitlab
    @alexflav23 I don't think it's the tuple syntax. 2.13.3 deprecated the optional ( ) when calling a method.
    Leif Ramming
    @leifblaese
    Hey guys,
    first of all, Phantom is an amazing library, thanks for creating it.
    I have one question though. Let's say that I have some table that I want to add a column to. How do I do it using phantom? Is there a way to auto-apply changes to the table as sort of an ALTER TABLE statement? I know that it is possible to automatically create the table if it does not exist, but how about updating it to match the scala model?
    Borzoo Esmailloo
    @Borzoo
    Hello folks,
    I have a question about context propagation (e.g. tracing). I couldn't find a proper way to preserve the data stored in thread local fields in future continuations. I tried passing in a custom executor which copies the thread local fields threading options but I does not work. I assume it's because of the way netty handles IO. I ended up creating a custom FutureMonad that copies the thread local fields (See this for more info). It seems to be working but I was wondering if there is a better way.
    rimeh bennjima
    @rimeh-bennjima
    hello @here, I have a question regarding the insert of type Instant in db cassandra with phantom .
    I have the time:
    import java.util.Instant
    val time = Instant.now()
    2020-12-02T15:40:55.197408Z
    I found in db the value : 2020-12-02T15:40:55.197Z
    have you an idea why the value change in cassandra? is it possible to insert the same created value?
    ehsanshah
    @ehsanshah

    hi every one
    this is my code

    def selectFromArgs(args: UUID*): Future[List[CompanyEntity]] = {
        selectInExample.flatMap(_.bind(ListValue(args: _*)).fetch())
      }

    I v got this error :
    Warning:(32, 35) Auto-application to () is deprecated. Supply the empty argument list () explicitly to invoke method list,
    or remove the empty argument list from its definition (Java-defined methods are exempt).
    In Scala 3, an unapplied method like this will be eta-expanded into a function.
    selectInExample.flatMap(_.bind(ListValue(values)).fetch())
    how can fix it

    1 reply
    ehsanshah
    @ehsanshah
    ????
    ehsanshah
    @ehsanshah
       ????

    and this code :

        def save(record: CompanyEntity): InsertQuery.Default[TblCompany, CompanyEntity] = {
          insert().value(_.idCompanyUUID, record.idCompanyUUID)
                  .value(_.nameMaster, record.nameMaster)
                  .value(_.companyName, record.companyName)
                  .value(_.domain, record.domain)
                  .value(_.whatIsPlan, record.whatIsPlan)
                  .value(_.dateRegister,record.dateRegister)
                  .value(_.isEnabled, record.isEnabled)
                  .value(_.mobileNo,record.mobileNo)
                  .value(_.email, record.email)
                  .value(_.website, record.website)
                  .value(_.isDelete, record.isDelete)
        }

    iv got this error :

    Warning:(51, 21) Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method value,
    or remove the empty argument list from its definition (Java-defined methods are exempt).
    In Scala 3, an unapplied method like this will be eta-expanded into a function.
                  .value(_.nameMaster, record.nameMaster)
    ehsanshah
    @ehsanshah
    is this silent group?
    ehsanshah
    @ehsanshah
    ???
    rimeh bennjima
    @rimeh-bennjima
    Hello @ehsanshah , try with
    def save(record: CompanyEntity): InsertQuery.Default[TblCompany, CompanyEntity] = {
          insert().value(_.idCompanyUUID, record.idCompanyUUID)()
                  .value(_.nameMaster, record.nameMaster)()
                  .value(_.companyName, record.companyName)()
                  .value(_.domain, record.domain)()
                  .value(_.whatIsPlan, record.whatIsPlan)()
                  .value(_.dateRegister,record.dateRegister)()
                  .value(_.isEnabled, record.isEnabled)()
                  .value(_.mobileNo,record.mobileNo)()
                  .value(_.email, record.email)()
                  .value(_.website, record.website)()
                  .value(_.isDelete, record.isDelete)()
        }
    rimeh bennjima
    @rimeh-bennjima
    and regarding the select query I have the same error and I don't have an idea how can I solve it .
    ehsanshah
    @ehsanshah

    @alexflav23 this is bug ?

    and this code :

        def save(record: CompanyEntity): InsertQuery.Default[TblCompany, CompanyEntity] = {
          insert().value(_.idCompanyUUID, record.idCompanyUUID)
                  .value(_.nameMaster, record.nameMaster)
                  .value(_.companyName, record.companyName)
                  .value(_.domain, record.domain)
                  .value(_.whatIsPlan, record.whatIsPlan)
                  .value(_.dateRegister,record.dateRegister)
                  .value(_.isEnabled, record.isEnabled)
                  .value(_.mobileNo,record.mobileNo)
                  .value(_.email, record.email)
                  .value(_.website, record.website)
                  .value(_.isDelete, record.isDelete)
        }

    iv got this error :

    Warning:(51, 21) Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method value,
    or remove the empty argument list from its definition (Java-defined methods are exempt).
    In Scala 3, an unapplied method like this will be eta-expanded into a function.
                  .value(_.nameMaster, record.nameMaster)
    voropaevp
    @voropaevp

    Hello, I struggle to get my head around the error I'm getting from insert

    [error]  ...\src\main\scala\modeling\model\ExchangeModel.scala:30:16: type mismatch;
    [error]  found   : modeling.model.ExchangeModel => x$4.open.type forSome { val x$4: modeling.model.ExchangeModel }
    [error]  required: modeling.model.ExchangeModel => com.outworkers.phantom.column.AbstractColumn[AnyVal]
    [error]       .value(_.open, record.open.toSecondOfDay)
    [error]                ^

    What is wrong with the type of _.open?

    abstract class ExchangeModel extends Table[ExchangeModel, Exchange] {
    
      override def tableName: String = "exchange"
    
      object id extends UUIDColumn with PartitionKey
    
      object name extends StringColumn with ClusteringOrder
    
      object timeZone extends StringColumn
    
      object open extends LongColumn
    
      object close extends LongColumn
    
      def save(record: Exchange):  Future[ResultSet] = {
        insert
          .value(_.id, record.id)
          .value(_.name, record.name)
          .value(_.timeZone, record.timeZone.toString)
          .value(_.open, record.open.toSecondOfDay)
          .value(_.close, record.close.toSecondOfDay)
          .future()
      }
    
      override def fromRow(row: Row): Exchange = {
        Exchange(
          id(row),
          name(row),
          TimeZone.getTimeZone(timeZone(row)),
          LocalTime.ofSecondOfDay(open(row)),
          LocalTime.ofSecondOfDay(close(row))
        )
      }
      }
    voropaevp
    @voropaevp
    case class Exchange( id: UUID,  name: String,  timeZone: TimeZone,  open: LocalTime,   close: LocalTime )
    voropaevp
    @voropaevp
    I've made it work with the extractor object, but it feels a bit like a hack. What would be a good way of telling phantom how to (de)serialize custom types
    such as LocalTime or such
    Flavian Alexandru
    @alexflav23
    You do have that
    Check out the docs, you can definitely add custom datatypes using implicits, and it 's fairly easy to do so.
    You simply implement roundtrip conversion based on an existing type.
    @ehsanshah This is a warning around a deprecrated syntax in code produced by a macro
    It's not something that is related to your code necessarily
    Phantom will be patched shortly to remove this warning, but that's why you are seeing the issue
    @leifblaese We have this feature in phantom-pro, which performs automated migrations by applying patches with ALTER or other appropiate statements, and in effect it allows you to calculate schema diffs.
    @rimeh-bennjima that looks like a bug, would you mind filling an issue on GitHub, and we can take a look at it.
    Andrés García
    @andresgarciac

    Hi, @alexflav23 I've upgraded to 2.59.0 from 2.13.4 phantom-dsl.

    I had this function to execute batch statements. (specifically LWT Inserts)

      private def writeRequest(writeRequests: Seq[Batchable with ExecutableStatement]): Future[ResultSet] =
        Batch.logged.add(writeRequests.iterator).consistencyLevel_=(writeConsistencyLevel).future()

    Since I upgrade to 2.59.0 I had to remove ExecutableStatement because it's gone and it was the only change I did and it looks like it works, not compilation errors.

      private def writeRequest(writeRequests: Seq[Batchable]): Future[ResultSet] =
        Batch.logged.add(writeRequests.iterator).consistencyLevel_=(writeConsistencyLevel).future()

    But in execution time many WriteTimeOutExeptions CAS started to be thrown something that didn't happen with the 2.13.4 version.

    Failed to execute query com.datastax.driver.core.BatchStatement@68701d38
    
    com.datastax.driver.core.exceptions.WriteTimeoutException: Cassandra timeout during CAS write query at consistency LOCAL_SERIAL (2 replica were required but only 1 acknowledged the write)
      at com.datastax.driver.core.exceptions.WriteTimeoutException.copy(WriteTimeoutException.java:104)
      at com.datastax.driver.core.Responses$Error.asException(Responses.java:162)

    I'm struggling to try to figure out what's the cause, Does someone knows what would be happening?

    Tom Reeve
    @TRReeve
    @andresgarciac are there definitely enough nodes responsive? If the writes happening on one but the replication isn't happening then that can be something on the infrastructure side worth eliminating if you have an unavailable node or similar.
    13human
    @13human
    @alexflav23 is project not supported anymore? No any movements in outworkers/phantom#914
    Артём Корсаков
    @artemkorsakov

    Hi!
    I want to select a query from a table with a name containing "_", for example: SELECT * FROM some_keyspace.some_table_name;

    According to the doc, I named my class like this:
    abstract class Some_table_name extends table [Some_table_name, Result]

    Can I escape the "_" in the class name?