When using the .sql method on IgniteRDDs, I need to have the "table" name to do the WHERE clause. I don't know how to retrieve it, and the example provides the name Integer for an [Int, Int] type cache. I have tried recreating it with [String, Int] caches etc. but haven't been able to figure out how they got that Integer name.
Does it have to do with Spark naming conventions, or is it a part of Ignite?
It seems a simple issue, but I just can't find the RDD's table name.
Their example can be viewed here: https://github.com/apache/ignite/blob/master/examples/src/main/spark/org/apache/ignite/examples/spark/SharedRDDExample.java
Config file: https://github.com/apache/ignite/blob/master/examples/config/spark/example-shared-rdd.xml
In configuration you can find:
<property name="indexedTypes">
<list>
<value>java.lang.Integer</value>
<value>java.lang.Integer</value>
</list>
</property>
this is a list key(odd) and value(even) types which would be indexed. more details you can find here: https://apacheignite-sql.readme.io/docs/schema-and-indexes#section-registering-indexed-types
The table has a name of value type, in this case, it's "Integer".
Related
I have a bit of an SQL/Hive challenge.
In the DB, we receive the output of our XML like below. Which includes the name & value of XML records.
The value I am querying will look like:
rollover\5000,another\10000, rollover\1000, BillingTimeStamp\2017-06-15T01:00:05,timereset\2017-05-26T14:32:51
Which is derived from an XML tree that would look a bit like:
<property>
<name>rollover</name>
<value>5000</name>
</property>
<property>
<name>another</name>
<value>5000</name>
</property>
<property>
<name>rollover</name>
<value>7000</name>
</property>
...
So, I need to query and say:
IF this string includes the word rollover, sum the value. The problem is, the term rollover can appear multiple times, with multiple values.
The 'rows' are delimited by , and the columns by \
So the output if I were to split at a comma would be:
rollover\5000
another\5000
rollover\7000
...
Can anyone advise where I might even start? I've tried a few string functions and taking the value between the \ and the comma, but I don't know how to iterate over the string to find all occurrences.
Any help would be amazing!
SELECT
CASE
WHEN "rollover" in "rollover\5000,another\5000, rollover\7000, BillingTimeStamp\2017-06-15,timereset\2017-05-26"
THEN
I have a problem:
I use (it is a constraint)
solr 4.10.3
I have already a collection
with a lot of documents
that uses a schema.xml
with static and dynamic fields.
Unfortunately,
in the file schema.xml
there are already dynamic fileds
for all types (string, text, int, etc..)
except for the type "date" .
Now, I need that in the collection
must be present also a dynamic field with type "date".
Is it enough to add in the schema.xml (the type "date"
is already defined in the schema.xml) the following item ?:
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
So (important for me), after this adding of dynamic field,
is it only necessary to
perform the 2 proper commands of zkcli.sh (commands upconfig and linkconfig)?
Is it (after) also necessary the reindexing of the collection?
(I hope no, maybe, because I added only a dynamic field (in the schema)
and not static field, the reindexing is not necessary, I hope).
In case I need the reindexing of the collection, how can I perform it ?
Thanks for a possible help.
Regards.
Fabrizio
Whether reindexing is required is not dependent on the type (i.e. dynamic or static) of the field; only whether you want to change any data that has already been indexed for the field - or add data that isn't in existing documents, but is present in your original data source.
As long as the content is only meant to be present in any document being indexed after you've updated your schema, adding a dynamic or static field does not require reindexing.
If the field has already been indexed under a different type, clearing out the index and reindexing is a necessity (although you might get away with doing atomic updates if all existing fields are set as stored - but I really recommend doing a full reindex in that case anyway, since you don't want your index to be in some sort of limbo while updates are being performed).
Is there any documentation available to get the list of available SQL datatypes used in the service.xml?
What value should I use to make the configuration compatible with the following table structure:
CREATE TABLE SAMPLE_TABLE (
NAME varchar(100) NOT NULL,
DESCRIPTION varchar(300) DEFAULT NULL,
CREATE_DATE timestamp
)
It always feels funny to link to the service-builder DTD (here the HTML version - just see the declaration at the top of your service.xml for the actual file), but you can actually learn a lot from it: It contains way more documentation than actual DTD code, so it's human readable for anybody dealing with service builder. In the DTD you'll find the attributes to declare that you want to connect to an existing table instead of creating one through servicebuilder default mechanisms.
There's another file, which AFAIK sadly does not have a DTD: model-hints.xml. However, luckily there's a developer guide chapter on it: This contains quite some extra information, like: max-length of VARCHAR fields etc. . Use this file for more validation or to specify more details for the columns that get autogenerated into your entity tables.
I have a DB-intensive function defined in MS SQL that computes a read-only property (LastCompletedDate) of an Inspection object. I don't usually need this information, so I'm not mapping it in Inspection.hbm.xml.
When I do need the info, I want to take an IEnumerable collection of Inspections, query the database to find their LastCompletedDate, and fill that in for each. Ideally, without making a separate trip to the database for each Inspection. I'm having trouble finding a way to do this in NHibernate (I'm a relative newbie to NHibernate). I'm thinking of something like:
CurrentSession.CreateQuery(
"select InspectionId, dbo.fn_GetLastCompletedDate(InspectionId)
from Inspection where InspectionId in :idList")
.SetParameter("idList", from InspectionList select InspectionId)
.List();
followed by a loop to pull out the dates and add them to the Inspection objects.
Is there a better way to do this? And what syntax do I need?
There are two possible options which I can think of.
Mark the property as lazy load
<property name="LastCompletedDate"
lazy="true"
formula="dbo.fn_GetLastCompletedDate(InspectionId)"/>
When performing a query to get all Inspection objects this property will not be loaded.
CurrentSession.CreateQuery("from Inspection")
.List<Inspection>();
But when including a hint this property will be loaded along with all other properties.
CurrentSession.CreateQuery("from Inspection fetch all properties")
.List<Inspection>();
The disadvantage of this approach is that this hint is only available when using HQL. Further details can be found here
http://ayende.com/blog/4377/nhibernate-new-feature-lazy-properties
The second option is to use a component with lazy load enabled.
<component name="lazy_load_items" lazy="true">
<property name="LastCompletedDate"
formula="dbo.fn_GetLastCompletedDate(InspectionId)"/>
</component>
Again this is lazy loaded so a normal query against the Inspection entity wouldn't result in the function being called for each row
CurrentSession.QueryOver<Inspection>.List();
But it can be eager loaded via any of the query APIs
session.QueryOver<Inspection>()
.Fetch(i => i.lazy_load_items).Eager
.List();
This disadvantage of this approach is that is requires an extra class to be created just to contain your single property.
UPDATE
On further testing it looks like eager loading of components only works with HQL using the fetch all properties hint. So the query example I gave is wrong and therefore so are the advantages for the component approach.
As the title: How would I tell NHibernate, once and for all, that all table and column names are to be quoted in the SQL it generates?
You can also try:
SchemaMetadataUpdater.QuoteTableAndColumns(configuration);
You need to add
<property name="hbm2ddl.keywords">auto-quote</property>
to your NHibernate configuration.
I've not tried this, but as far as i can determine based on the documentation a custom implementation of the naming strategy allows you to rewrite the table/column names thus also enables you to quote them.