Avro schema - optional fields - gives "Not in Union" exception

Hi all,
I have a problem with using optional fields in an avro schema and using the JSONAvroBinding.
If I have a User schema that has a first name field. The User can opt to provide the first name , or not. The field is optional from a readers perspective.
(this is taken from  http://docs.oracle.com/cd/NOSQL/html/GettingStartedGuide/avroschemas.html which is nosql avro documentation)
  "type": "record",
  "namespace": "com.example",
  "name": "FullName",
  "fields": [
    { "name": "first", "type": ["string", "null"] },
    { "name": "last", "type": "string", "default" : "Doe" }
Here if I supply this example as the Avro schema, and then omitt the first name when I write, it will work without problem. But when I attempt to write "John" it will fail with:
Caused By: org.apache.avro.UnresolvedUnionException: Not in union ["string","null"]: "John"
         at oracle.kv.impl.api.avro.JsonBinding$JsonData.resolveUnion(JsonBinding.java:403)
         at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:144)
         at oracle.kv.impl.api.avro.JsonBinding$JsonDatumWriter.write(JsonBinding.java:599)
         at oracle.kv.impl.api.avro.JsonBinding$JsonDatumWriter.writeRecord(JsonBinding.java:695)
         at oracle.kv.impl.api.avro.JsonBinding$JsonDatumWriter.write(JsonBinding.java:565)
         Truncated. see log file for complete stacktrace
This fails:
   "first" : "John",
   "last" : "Smith"
This works:
   "last" : "Smith"
It seems someone else had this problem and posted on AVROs site, where a response said it might be NoSQLs libraries fault:
"The error is thrown from the Oracle's NoSQL library's use of Avro and is not clearly an Avro problem. You might be better off trying to get help for this from Oracle?"
https://issues.apache.org/jira/browse/AVRO-1376
Any thoughts? To me this seems like a bug in the JsonBinding class?

According to this:
http://www.oracle.com/technetwork/database/nosqldb/learnmore/nosqldb-faq-518364.html#HowtouseAvrounionstoencodeoptionalfields
Sending in
   "first" : "John",
   "last" : "Smith"
is not correct.
Instead, sending in:
   "first" : {
     "string" : "John"
   "last" : "Smith"
is working.

Similar Messages

  • How to pass the Data to sclect option field in module pool??

    Hai Experts,
                         I have Created the Select-Options using Sub screen its working fine for me.
    But the problem is when i pass the data to one of the my select options field its not  showing  in display mode..
    please me this
    i created select option slike this,
    SELECTION-SCREEN BEGIN OF SCREEN 400 AS SUBSCREEN.
    SELECT-OPTIONS : s_kunnr  FOR wa_zcodntr-fin_kunnr,
                                  s_altkn FOR wa_zcodntr-altkn.
    SELECTION-SCREEN END OF SCREEN 400 .
    Thanks ,
    Adv.

    Thanks SAP_wiz kick replay,
    Actullay in my module pool screen i have to select option field like F1 and F2
    any one filed give the input and excute pick the coresponding data for F2 (select option) field and  display  and vice -versa.

  • In the previous version, the menu table in table options, there is an option that gives me the option: the Return key moves to next cell. I do not see this option in the new number. can you help me please?

    in the previous version  of Number, the menu table in table options, there is an option that gives me the option: the Return key moves to next cell. I do not see this option in the new number. can you help me please?

    Hi silvano,
    If you use a regular pattern when entering values, press enter (return) after entering the last value in a row. That will take you to the first Body Cell of the next row.
    Start in Cell B2
    1 Tab 2 Tab 3 Enter
    4 Tab 5 Tab 6 Enter
    7 Tab 8 Tab 9 Enter
    Now you are ready to type into B5 .
    Another way that some people find easier is to enter one column at a time
    Start at B2
    1 enter
    4 enter
    7 enter
    etc.
    Now start with C2.
    Use whatever suits your work flow.
    Regards,
    Ian.

  • How to give not null value in a rule for a field

    hi,
    i want to create a rule through rule designer where i want a field say "country" should not be left blank. when i go to the rule designer and select country through attribute value i get 2 conditions "=" and "!=" what shoud i give the value as so that the country field is not null.
    TIA

    I don't think you can have null value in the rule designer , rather you can created one more UDF and populate this UDF with something based on the nulllness/not-null of the country field and use this new UDF in the rule .
    Hope this helps .
    Thanks
    Suren

  • I am trying to purchase Creative Suite CS6 Design Standard. I own a Max OSX. I live in Germany.  When I try to order for Germany, it gives me only an option for Windows, not Mac.  How can I order?

    I am trying to purchase Creative Suite CS6 Design Standard. I own a Max OSX. I live in Germany.  When I try to order for Germany, it gives me only an option for Windows, not Mac.  How can I order?

    In Germany no telephone number nor web chat is available.  Searching on the Adobe site tells me that this forum is the only avialable means to ask consumer questions.  I am giving up and ordering from elsewhere.

  • Smartforms: Output Options for Field Contents not working within table

    Hello,
    to display an amount and its unit I am using &GS_MM_IT_GEN-MENGE(R)& &GS_MM_IT_GEN-MEINS& with a line of a table. Unfortunatly it seams that the output option "R" (right-justified) is not working with the table context. Has anyone an idea, what to do?
    Thanx,
    Peter

    Dear all,
    thank you for your suggestions. I have found out, that the output option work pretty well as described in the documentation. The are output options of a field and not of a column! To get a right justified column, I had to change the attribute of the parapraph assigned to the column.
    Regards
    Peter

  • Creating Custom fields does not have the option to create as a Note field

    Of course I have a sales VP that wants to be able to see what they are typing instead of having it scroll off the screen as they type (even though once they save the record the data is fully displayed).
    Before I go to customer care is there a way for me to request through support that two custom fields I created as Text (Long) can be changed (or new ones created) behind the scenes as a Note field similar to the Comments field? Note is not an user option when creating a custom field.
    I ucan not just rename the description field in the account record as I am already using that field for comments.
    Thanks,
    Caryn

    It is not possible at this time to create a custom Note field. This is something that is on the On Demand roadmap as a enhancement.

  • Bought a new laptop.  Have an iPad 4 that I have not updated to iOS 7 yet.  I plugged it in, wanting to back it up before I update it, when I right click on the device the ONLY option it gives me is "eject".  why?

    Bought a new laptop.  Have an iPad 4 that I have not updated to iOS 7 yet.  I plugged it in, wanting to back it up before I update it, when I right click on the device the ONLY option it gives me is "eject".  why?

    There's an article that Apple has acknowledged this issue. They recommend turning off imessages, reset all settings and then reactivate imessages.
    If that doesn't work, you may just have to wait until they release an update, which should be pretty soon.

  • Transaction History Not Displaying all Optional Fields

    Hey all, Looking for some help with transaction history reports.  I've seen some others have posted about this in years past, but, never saw a positive response so I thought I would throw it out there once again. Essentially, the transaction history report is only showing 2 option fields and dropping the 3rd.  So, in my report, I see Option 1 Field, Option 1 Value, Option 2 Field, and Option 2 Value.  What I DO NOT see is Option 3 Field and Option 3 Value.  However, I have confirmed that for each of my individual transactions, the data is there.  The report system just appears not to be picking it up. Has anyone else seen this and know of a method to resolve this?   thanks!KSAT  

    I think they support only upto two options in the report. Even the documentation shows the same - https://developer.paypal.com/docs/classic/admin/download-history/ I hope at least they will include a new field to dump all the additionall options and values as it is crucial information for us to ship the item.

  • When I drag an image over a clip to try and get picture in picture the options it gives me are only insert replace and delete not the picture in picture option how do i get the picture in picture option when i drag a picture over a clip

    When I drag an image over a clip to try and get picture in picture the options it gives me are only insert replace and delete not the picture in picture option how do i get the picture in picture option when i drag a picture over a clip?

    Go to this. http://help.apple.com/imovie/mac/10.0/#mova1aaa682b . It is the link to show you how to use picture in picture. I had this same problem not too long ago.

  • "Field Catalog not found" ...problem in ALV reporting !!

    Hi,
    When i execute my report program where in I generate a Selection screen, I am able to select the values in the selection screen. Once I click on the execute button I get the message
    "Field Catalog not found"...
    The elabore message is
    "Field Catalog cannot be determined becaus the output table structure name was not specified"
    Where am I wrong ??
    Find below my code ...
    *& Report  Z_MIGO_TXJCD_REPORT
    REPORT  Z_MIGO_TXJCD_REPORT.
    TYPE-POOLS: slis.
    TABLES:  makt,mseg,zmigo_extend,ttxj,mkpf.
    DATA: BEGIN OF migo_data OCCURS 0,
           matnr LIKE mseg-matnr,
           werks LIKE mseg-werks,
           lgpla LIKE mseg-lgpla,
           bwart LIKE mseg-bwart,
           menge LIKE mseg-menge,
           dmbtr LIKE mseg-dmbtr,
           budat LIKE mkpf-budat,
           txjcd LIKE zmigo_extend-txjcd,
          END OF migo_data.
    DATA: it_cat TYPE slis_t_fieldcat_alv,
          wa_lay TYPE slis_layout_alv.
    FIELD-SYMBOLS: <fs_cat> LIKE LINE OF it_cat.
    SELECT-OPTIONS: so_matnr FOR makt-matnr,
                    so_budat FOR mkpf-budat,
                    so_werks FOR mseg-werks,
                    so_lgpla FOR mseg-lgpla,
                    so_bwart FOR mseg-bwart,
                    so_txjcd FOR ttxj-txjcd.
    START-OF-SELECTION.
      SELECT amatnr awerks algpla abwart
             amenge admbtr bbudat ctxjcd INTO TABLE
             migo_data
        FROM mseg AS a INNER JOIN mkpf AS b ON amblnr = bmblnr INNER JOIN
             zmigo_extend AS c ON amblnr = cmblnr
       WHERE a~matnr IN so_matnr
         AND b~budat IN so_budat
         AND a~werks IN so_werks
         AND a~lgpla IN so_lgpla
         AND a~bwart IN so_bwart
         AND c~txjcd IN so_txjcd.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-cprog
          i_internal_tabname     = 'migo_data'
          i_inclname             = sy-cprog
        CHANGING
          ct_fieldcat            = it_cat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      LOOP AT it_cat ASSIGNING <fs_cat>.
        CLEAR <fs_cat>-key.
      ENDLOOP.
      wa_lay-zebra = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_grid_title  = 'MIGO report with Tax Jurisdiction Code'
          is_layout     = wa_lay
          it_fieldcat   = it_cat
        TABLES
          t_outtab      = migo_data
        EXCEPTIONS
          program_error = 1
          OTHERS        = 2.

    Give 'migo_data' in uppercase as ''MIGO_DATA'.

  • Tax Jurisdiction in SAP CRM 7.0 B2C Webshop as an optional field.

    Hi Everyone,
    We are  trying to register a user in B2C Webshop .In the process of registering, On entering the postal  Code and  corresponding city , the application shows an error message which says " Tax Jurisdiction could not be detremined" .
    Going ahaed, we could like some clarity on the same .It would  also be relevant if we could make this postal code/City as an optional filed in the System.We need clarity  on making this as an optional field.
    KIndly give your inputs if any one has worked on the same functionality.
    Thanks in advance.
    Regards
    Sanjib paul

    See if the configuration settings at (Tcode SPRO)
    CRM--> Master Data --> Business Partner --> Specify handling of error messages helps.
    Also see my replies in other threads on suppressing or showing CRM messages in the web (ISA) layer.
    Re: Product not viewable in catalog nor in search function but still orderable
    Re: Minimum order quan - CRMC_MSGC
    Re: Minimum order quan - CRMC_MSGC

  • Tax Jurisdiction In B2C Webshop (SAP CRM 7.0) as an optional field.

    Hi Everyone,
    We are trying to register a user in B2C Webshop .In the process of registering, On entering the postal Code and corresponding city , the application shows an error message which says " Tax Jurisdiction could not be detremined" .
    Going ahaed, we could like some clarity on the same .It would also be relevant if we could make this postal code/City as an optional filed in the System.We need clarity on making this as an optional field.
    KIndly give your inputs if any one has worked on the same functionality.
    Thanks in advance.
    Regards
    Sanjib paul

    See if the configuration settings at (Tcode SPRO)
    CRM--> Master Data --> Business Partner --> Specify handling of error messages helps.
    Also see my replies in other threads on suppressing or showing CRM messages in the web (ISA) layer.
    Re: Product not viewable in catalog nor in search function but still orderable
    Re: Minimum order quan - CRMC_MSGC
    Re: Minimum order quan - CRMC_MSGC

  • Disable the Select-options field in the viewcontainer

    Hi,
    I  have two select option fields(Date,Number) in a viewcontainer .
    Now i need to disable one of the select-option field(Date) in the view container based on the condition.If I give Enability for the view container then both the select options will get diasbled.Is there any way to disable only Date select-option field in the view container.
    Thanks in Advance.
    Regards,
    bala.

    Hi,
    I just tested this solution and it is working for me....Following on Thomas's suggestion...I did the following....
    I just had one select-option on my scr...but it can be done with two too...
    step1: 
    created three attributes at component level under the attribute tab ( as suggested by Thomas )
    ENABLE_PRI_SELECTOPTION type  WDY_BOOLEAN 
    M_HANDLER type ref to     IF_WD_SELECT_OPTIONS
    M_WD_SELECT_OPTIONS  type ref to     IWCI_WDR_SELECT_OPTIONS
    Note: all are with public check box checked....so that all your views can see these attributes
    I created a method at componenet controller leverl:  create_select_option....in this method i have following code:
    DATA:
      lt_range_table TYPE REF TO data,
    *  rt_range_table TYPE REF TO data,
      read_only TYPE abap_bool,
      typename TYPE string.
      DATA:
      lr_componentcontroller TYPE REF TO ig_componentcontroller,
      l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
    * create the used component
      l_ref_cmp_usage = wd_this->wd_cpuse_select_options( ).
      IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
        l_ref_cmp_usage->create_component( ).
      ENDIF.
    * get a pointer to the interface controller of the select options
    *component
      wd_this->m_wd_select_options = wd_this->wd_cpifc_select_options( ).
    * init the select screen
      wd_this->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).
    * create a range table that consists of this new data element
      lt_range_table = wd_this->m_handler->create_range_table(
      i_typename = 'PERSNO' ).
    * add a new field to the selection
      wd_this->m_handler->add_selection_field(
      i_id = 'PERSNO'
    I_VALUE_HELP_TYPE = if_wd_value_help_handler=>CO_PREFIX_SEARCHHELP
    I_VALUE_HELP_ID = 'ZHELP_WDA_PERNR'
    I_NO_INTERVALS = abap_true
      it_result = lt_range_table
      i_read_only = wd_this->ENABLE_PRI_SELECTOPTION ).   <-----pls see here how i am controlling the read only property
    I assume you know this much...already....but i am just putting everything down....
    step2:
    in my view where i want to display the select-options....i added this code under my wddoinit method
    DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
    lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
    lo_componentcontroller->ENABLE_PRI_SELECTOPTION = abap_false.    <--pls see initially we want this field to be open
      lo_componentcontroller->create_select_option(
    step3: 
    i did not have much logic to control the select option field so i added a button which if user presses the field become disable...
    under that button action method i added the following code:
    DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
    lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
    lo_componentcontroller->ENABLE_PRI_SELECTOPTION = abap_true.
       "<---pls see here how i am changing the global *attribute which Thomas has suggested for controlling the "read only" attibute for the select-option field....you can put this under *your "if" statement....
    "this step is very important if you do not remove the field you will get the dump...since it will try to add the same field again
    "which produces dump from system....
    lo_componentcontroller->m_handler->REMOVE_SELECTION_SCREEN_ITEM(
    i_id = 'PERSNO' ).
    "now call the same method which we created at component level to create the select_options...
    lo_componentcontroller->create_select_option(
    that is all....it works great for me.....let us know if still have any questions....
    Thanks...
    AS...

  • Mandatory Select-options field problem

    Hello Gurus,
    I have the below scenario:
    In my Z report I am having a select-options for material selection(s_matnr) on selection screen and that is a mandatory field.
    But when the user tries to enter the multiple single values by pressing the arrow icon present near the select-option it gives an error message " Fill in all the required entries "
    So the problem is I cannot enter the multiple single values in select-options until and unless I fill s_matnr-low. Once I fill s_matnr low then its allowing to enter multiple standard values.
    And as per the requirement the user must be able to enter the multiple single values in s_matnr even if s_matnr-low is not populated.
    Is this the standard functionality of SAP or there is some way out of it?
    <removed_by_moderator>
    Thanks in advance.
    Edited by: Julius Bussche on May 8, 2009 7:59 AM

    Hi Sachin,
    Remove the obligatory addition from the declaration of the select-option....
    see the example code below .... it will help you resolve your issue for sure.....
    TABLES : scarr, sscrfields. " Tables sscrfields is a must to be declared in your code...
    SELECT-OPTIONS : carrid FOR scarr-carrid.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF screen-name CS 'CARRID'.
          screen-required = 2.                " though obligatory is not mentioned it will give you tick mark
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    AT SELECTION-SCREEN.
      IF sscrfields-ucomm = 'ONLI'.
        IF carrid IS INITIAL.
          CLEAR sscrfields.
          MESSAGE 'Fill in all required entries' TYPE 'E'.       " once the user press F8 then only this error
    " message will be displayed
        ENDIF.
      ENDIF.
    Regards,
    Siddarth

Maybe you are looking for