Custom Schema Definitions
In addition to Automatic Schema Discovery the adapter also allows you to statically define the schema for your Cassandra object. Let's consider the schema below and extract out the nested properties as their own columns:
{
id: 12,
name: "Lohia Manufacturers Inc.",
address: {street: "Main Street", city: "Chapel Hill", state: "NC"},
offices: ["Chapel Hill", "London", "New York"]
annual_revenue: 35,600,000
}
{
id: 15,
name: "Piago Industries",
address: {street: "Main Street", city: "Durham", state: "NC"},
offices: ["Durham", "San Francisco"]
annual_revenue: 42,600,000
}
Custom Schema Definition
You can define a custom schema to extract out nested properties as their own columns. The following schema uses the other:periodpath property to define where the data for a particular column should be retrieved from. Using this model you can flatten arbitrary levels of hierarchy.
The table attribute specifies the table to parse. The table attribute gives you the flexibility to use multiple schemas for the same table. If table is not specified, the filename determines the table that is parsed.
<rsb:script xmlns:rsb="http://www.rssbus.com/ns/rsbscript/2">
<rsb:info title="Customers" description="Customers">
<!-- Column definitions -->
<attr name="Id" xs:type="int" key="true" />
<attr name="Name" xs:type="string" />
<attr name="Street" xs:type="string" other:periodpath="address.street" />
<attr name="City" xs:type="string" other:periodpath="address.city" />
<attr name="PrimaryOffice" xs:type="string" other:periodpath="offices.0" />
<attr name="SecondaryOffice" xs:type="string" other:periodpath="offices.1" />
</rsb:info>
<rsb:set attr="table" value="customers"/>
</rsb:script>
In Custom Schema Example, you will find the complete schema that contains the example above.