Re: [basex-talk] Interrupted queries - partial results?
Thanks! That should do it! Patrick On 4/19/22 11:40, Zimmel, Daniel wrote: How about some custom logging? for $i in (1 to 10) return if ($i = 4) then error() else file:append-text-lines('C:\tmp\file',string($i)) There might be more sophisticated ways. Daniel -Ursprüngliche Nachricht- Von: BaseX-Talk Im Auftrag von Patrick Durusau Gesendet: Dienstag, 19. April 2022 16:45 An: basex-talk@mailman.uni-konstanz.de Betreff: [basex-talk] Interrupted queries - partial results? Greetings! Is it possible to capture partial results from an interrupted query? When I realize a query is taking too long for the data involved, it might be helpful in correcting the mistake. Thanks! Patrick -- Patrick Durusau patr...@durusau.net Technical Advisory Board, OASIS (TAB) Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300 Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps) Another Word For It (blog): http://tm.durusau.net Homepage: http://www.durusau.net Twitter: patrickDurusau -- Patrick Durusau patr...@durusau.net Technical Advisory Board, OASIS (TAB) Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300 Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps) Another Word For It (blog): http://tm.durusau.net Homepage: http://www.durusau.net Twitter: patrickDurusau OpenPGP_signature Description: OpenPGP digital signature
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
On Tue, Apr 19, 2022 at 07:51:34PM +0200, Markus Elfring scripsit: > > Here's one thing you may be asking - do you want to know how to > > specify a join for n sources? > > Yes. ‒ Your enquiry points into a direction for which I am looking > also for further solution ideas. If you look at Jonathan's example, you may recognize that the type of the variables is element()+, that is, a sequence of one or more elements. You might then get the idea that instead of all those equals signs, you can treat it as a grouping problem: declare variable $eng := (one, two, three, four); declare variable $deu := (eins, zwei, drei, vier); declare variable $ukr := (один, два, три, чотири); declare variable $heb := (אחד, שתיים, שלוש, ארבע); let $range as xs:string* := ($eng,$deu,$ukr,$heb)/@n/string() => distinct-values() => sort() (: the sort() is compulsive neatness, it is not required :) for $index in $range return {($eng,$deu,$ukr,$heb)[@n eq $index]} Once you recognize the grouping problem, you can go "wait, isn't there a clause for that?" declare variable $eng := (one, two, three, four); declare variable $deu := (eins, zwei, drei, vier); declare variable $ukr := (один, два, три, чотири); declare variable $heb := (אחד, שתיים, שלוש, ארבע); for $ref in ($eng,$deu,$ukr,$heb) let $key as xs:string := $ref/@n/string() group by $key return {$ref} Note that this will work whether or not any particular language has that value of n, and you can of course define a function to go create your sequences. It isn't always a grouping problem, but the base pattern -- treat sequences as sequences, and all shall be well -- holds broadly. That's why there's no impetus to define a specific join operator; you'd have to stuff the entire language into it to get equivalent functionality, and we already have the entire language. -- Graydon Saunders | graydon...@gmail.com Þæs oferéode, ðisses swá mæg. -- Deor ("That passed, so may this.")
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
> Here's one thing you may be asking - do you want to know how to specify a > join for n sources? Yes. ‒ Your enquiry points into a direction for which I am looking also for further solution ideas. > for $e in $eng > for $d in $deu > for $u in $ukr > for $h in $heb > where $e/@n = $d/@n > and $e/@n = $u/@n > and $e/@n = $h/@n > return > { $e, $d, $u, $h } Will any improvements become relevant for the specification of such join conditions? Regards, Markus
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
On Tue, 2022-04-19 at 12:42 -0400, Jonathan Robie wrote: > Here's one thing you may be asking - do you want to know how to > specify a > join for n sources? I think the question was, what if n is large or dynamic. But then we fall back to needing a use case because the best strategy depends on circumstance and people. XQuery and XSLT are much more dynamic language than SQL, in the way they feel. You're not really doing a SQL-style join so much as programming with relationships, which is more like working with an ER diagram i suppose, but at a micro level. Yes, the underlying XQuery engine is doing things like joins and making tuple-streams, and that's pretty fundamental, but it's implicit and pervasive. let $me := $here/@id return /doc/people/person[@postcode = $id] might be thought of as doing a join on the id attribute of person elements even though it's not in a FLWOR expression. So part of moving to XQuery (as with XSLT) is a change in the way we think of data and how we think of processing data. And i think think that's the hardest part for many people. It can start as simply as understanding why "for" in XQuery (and "for-each" in XSLT) isn't a loop. There might be some mileage in a document, "XQuery for SQL programmers" :) liam -- Liam Quin, https://www.delightfulcomputing.com/ Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
Here's one thing you may be asking - do you want to know how to specify a join for n sources? If so, maybe this example will help: declare variable $eng := (one, two, three, four); declare variable $deu := (eins, zwei, drei, vier); declare variable $ukr := (один, два, три, чотири); declare variable $heb := (אחד, שתיים, שלוש, ארבע); for $e in $eng for $d in $deu for $u in $ukr for $h in $heb where $e/@n = $d/@n and $e/@n = $u/@n and $e/@n = $h/@n return { $e, $d, $u, $h } This returns: one eins один אחד two zwei два שתיים three drei три שלוש four vier чотири ארבע Does that answer your question? I routinely do queries that join multiple sources. Jonathan On Tue, Apr 19, 2022 at 6:04 AM Markus Elfring wrote: > > Have you read the XQuery specifications? > > Yes. > > > > This section on joins, written by one of the inventors of SQL, may be a > helpful starting point: > > > > https://www.w3.org/TR/xquery-31/#id-joins > > It seems that I stumble on communication difficulties for this application > area. > > Regards, > Markus >
Re: [basex-talk] Interrupted queries - partial results?
How about some custom logging? for $i in (1 to 10) return if ($i = 4) then error() else file:append-text-lines('C:\tmp\file',string($i)) There might be more sophisticated ways. Daniel -Ursprüngliche Nachricht- Von: BaseX-Talk Im Auftrag von Patrick Durusau Gesendet: Dienstag, 19. April 2022 16:45 An: basex-talk@mailman.uni-konstanz.de Betreff: [basex-talk] Interrupted queries - partial results? Greetings! Is it possible to capture partial results from an interrupted query? When I realize a query is taking too long for the data involved, it might be helpful in correcting the mistake. Thanks! Patrick -- Patrick Durusau patr...@durusau.net Technical Advisory Board, OASIS (TAB) Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300 Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps) Another Word For It (blog): http://tm.durusau.net Homepage: http://www.durusau.net Twitter: patrickDurusau
Re: [basex-talk] Improving the understanding for counting of entries in data groups
If the following result is the one you would expect … topic_combination|incidence Test1*Test2*Test3|3 Demo1*Demo2|2 Probe1|1 … it is sufficient to replace … > let $incidence := count($topics) … by … let $incidence := count($x) The string join yields a single item, which is assigned to $topics; thus, count($topics) returns 1. Grouped values will be assigned to the variables that have been declared before the 'group by' clause. This means that count($x) returns … • 1 if it’s called before 'group by' • the number of grouped items if it’s called after 'group by'
[basex-talk] Improving the understanding for counting of entries in data groups
Hello, I constructed the following XML file for another test of the software “BaseX 9.7”. 12 Demo1 Demo2 23 Demo1 Demo2 34 Test1 Test2 Test3 45 Test1 Test2 Test3 56 Test1 Test2 Test3 67 Probe1 I tried the following XQuery script out accordingly. declare option output:method "csv"; declare option output:csv "header=yes, separator=|"; for $x in //test_data/info group by $topics := string-join($x/topics/topic/data(), "*") let $incidence := count($topics) order by $incidence descending return {$topics} {$incidence} Corresponding test result: topic_combination|incidence Demo1*Demo2|1 Test1*Test2*Test3|1 Probe1|1 I would like to see the numbers “2” and “3” instead at the end of two rows for such a data analysis approach. I would appreciate further advices for this use case. Regards, Markus
[basex-talk] Interrupted queries - partial results?
Greetings! Is it possible to capture partial results from an interrupted query? When I realize a query is taking too long for the data involved, it might be helpful in correcting the mistake. Thanks! Patrick -- Patrick Durusau patr...@durusau.net Technical Advisory Board, OASIS (TAB) Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300 Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps) Another Word For It (blog): http://tm.durusau.net Homepage: http://www.durusau.net Twitter: patrickDurusau OpenPGP_signature Description: OpenPGP digital signature
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
> Have you read the XQuery specifications? Yes. > This section on joins, written by one of the inventors of SQL, may be a > helpful starting point: > > https://www.w3.org/TR/xquery-31/#id-joins It seems that I stumble on communication difficulties for this application area. Regards, Markus
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
Hi Markus, Have you read the XQuery specifications? This section on joins, written by one of the inventors of SQL, may be a helpful starting point: https://www.w3.org/TR/xquery-31/#id-joins The use case documents may also be helpful: https://www.w3.org/TR/xquery-use-cases/ https://www.w3.org/TR/xquery-30-use-cases/ https://www.w3.org/TR/xquery-31-requirements/ Please read up on joins in these places, I think it will help establish common ground for this conversation. Jonathan On Tue, Apr 19, 2022, 04:32 Markus Elfring wrote: > > To join something, you minimally need at least two expressions which find > > the things to be joined, > > I am still trying to clarify corresponding development possibilities > according to > bigger numbers of entities together with for clauses. > (I hope that other meanings can be better distinguished from related > applications > of a function like “string-join”.) > > > > some kind of rule for how to perform the join, > > and a destination for the result of the join. > > This is usual. > > > > [predicates aren't joins] > > How does this feedback fit to other documentations which describe the role > of > predicates for join operations? > > > > A join requires the results of two expressions to be combined. > > > > > (db:open('thing1'),db:open('thing2'))/descendant::patienti-identifier[local:check-range($interesting,.)] > > > > can be interpreted as a performing a join, you can re-write it as > > > > > (db:open('thing1')/descendant::patient-identifier[local:check-range($interesting,.)],db:open('thing2')/descendant::patient-identifier[local:check-range($interesting,.)]) > > > > but the predicate isn't doing the joining, the predicate is narrowing > > the selection of the XPath expressions. > > This can be a desirable effect. > > > > In this case, the comma operator is doing the joining. > > This example refers to another variant of a join operation for the > construction > of a sequence. > (Such a XQuery code fragment does not use for clauses.) > > > > > Do you care for the number of involved items here? > > > > No. > > Would you like to adjust this view according to the usage of for clauses? > https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-joins > > Regards, > Markus >
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
> I was asking for your personal uses case or examples, My use cases can be similar to the example application from the XQuery specification. > and I think this is what others have been asking you for as well. I am trying to point further development possibilities out according to varying and growing numbers of entities which would be referenced in for clauses. Regards, Markus
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
> An example application was published already with the XQuery 3.1 specification > for the combination of information from three documents. > https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-joins I have seen this link. I was asking for your personal uses case or examples, and I think this is what others have been asking you for as well.
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
> Could you please get specific and provide real use cases and examples? An example application was published already with the XQuery 3.1 specification for the combination of information from three documents. https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-joins Would you occasionally like to join significantly more entities (with for clauses according to known relationships)? Regards, Markus
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
Hi Markus, Could you please get specific and provide real use cases and examples? Thanks, Christian On Tue, Apr 19, 2022 at 10:46 AM Markus Elfring wrote: > > > > I propose once more to take another look at specification efforts for > > > join conditions (or constraints). > > > > What specific problem is it that you're trying to solve? What thing do > > you want to do that you do not believe you can do in XQuery? > > I imagine that join parameters can be passed to customised functions > so that for clauses would dynamically be constructed for further data > processing. > Will a function like “xquery:eval” be called finally? > > Regards, > Markkus
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
> > I propose once more to take another look at specification efforts for > > join conditions (or constraints). > > What specific problem is it that you're trying to solve? What thing do > you want to do that you do not believe you can do in XQuery? I imagine that join parameters can be passed to customised functions so that for clauses would dynamically be constructed for further data processing. Will a function like “xquery:eval” be called finally? Regards, Markkus
Re: [basex-talk] Joining a varying number of information sources (with XQuery)?
> To join something, you minimally need at least two expressions which find > the things to be joined, I am still trying to clarify corresponding development possibilities according to bigger numbers of entities together with for clauses. (I hope that other meanings can be better distinguished from related applications of a function like “string-join”.) > some kind of rule for how to perform the join, > and a destination for the result of the join. This is usual. > [predicates aren't joins] How does this feedback fit to other documentations which describe the role of predicates for join operations? > A join requires the results of two expressions to be combined. > > (db:open('thing1'),db:open('thing2'))/descendant::patienti-identifier[local:check-range($interesting,.)] > > can be interpreted as a performing a join, you can re-write it as > > (db:open('thing1')/descendant::patient-identifier[local:check-range($interesting,.)],db:open('thing2')/descendant::patient-identifier[local:check-range($interesting,.)]) > > but the predicate isn't doing the joining, the predicate is narrowing > the selection of the XPath expressions. This can be a desirable effect. > In this case, the comma operator is doing the joining. This example refers to another variant of a join operation for the construction of a sequence. (Such a XQuery code fragment does not use for clauses.) > > Do you care for the number of involved items here? > > No. Would you like to adjust this view according to the usage of for clauses? https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-joins Regards, Markus