Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-28689

Unable to successfully issue spark sql code

    XMLWordPrintableJSON

Details

    • Question
    • Status: Resolved
    • Minor
    • Resolution: Invalid
    • 2.4.3
    • None
    • Build
    • None

    Description

      Hello Community,

      My first post here, so please forgive me if I'm not following protocol.

      I'm trying to run the following code, however I keep on getting the error

      Invalid number of arguments for function add_months. Expected: 2; Found: 1;

      Even though, I certain I have two arguments. 

      Can someone take a look at the code and let me know where I might be going wrong.

       

      test5 = spark.sql("""SELECT
      TRX_EVENT_END AS TRX_EVENT
      ,SALES_QUANTITY
      FROM Transactions
      WHERE TRX_EVENT_END BETWEEN CAST(YEAR(DATE_ADD(CURRENT_DATE(),-1)) AS CHAR(4))+ RIGHT('0' + CAST(ADD_MONTHS(DATE_ADD(CURRENT_DATE(),-1))AS VARCHAR(2)),2) + '01'AND LAST_DAY(DATE_ADD(CURRENT_DATE(),-1))""")

       

      Thanks

       

      Carlton

      Attachments

        Activity

          People

            Unassigned Unassigned
            cpatte7372 CARLTON PATTERSON
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: