Adding an auto-generated number in table row in asciidoc file - asciidoc

Hi so I want to add "auto-generated" row number into a table in asciidoc file. I have something like this.
.Sample Table
[cols=2, options="header"]
|===
|ID | Description
|1
|This is row #1
|2
|This is row #2
|===
Where 1 and 2 are hardcoded. Is there a way to make them auto-generated? Like how we can have "." in list view to become numbers.
Thanks,
KT.

Try using the {counter} attribute. Here's a tutorial.

Related

Datatable populates items not as expected

I have a datatable. My problem is, that the template generates a new row for each item, but all should be in one row.
Please see this example
Expected output is
col1 | col2 | col3 | col4 |
--------------------------
AAA | BBB | CCC | DDD |
Also tried a td v-for, but its still generating too much rows. I think the template is also doing a v-for behind the scenes, but treating every single item as a new row and not as a td.
What im doing wrong here?
working with this workaround i guess: https://codepen.io/anon/pen/Bgbzrr
changes in datatable:
:items="rows"
changes in model:
rows:[{row:1}],

Fetch all names into multi row block

I have tables that looks like this:
tbl1
+---------+
|c_no |
+---------+
|1 |
+---------+
tbl2
+----------+---------+
|tbl1_c_no |s_name |
+----------+---------+
|1 |A |
|1 |D |
+----------+---------+
My form:
◘ The 1st block's base table usage is tbl1.
◘ C_NO field is auto generated using sequence. (required).
◘ S_GR is just an unbound item. (not required).
◘ The 2nd block's base table usage is tbl2 and is multiple row.
◘ S_NAME. (required)
◘ 1st block is like the parent of 2nd block.
◘ 1st and 2nd block is linked using c_no and tbl1_c_no
For example if I wanted to add some data, it's like this:
Then press F10 for saving:
tbl1 will be:
+---------+
|c_no |
+---------+
|1 |
|2 |
+---------+
tbl2 will be:
+----------+---------+
|tbl1_c_no |s_name |
+----------+---------+
|1 |A |
|1 |D |
|2 |B |
|2 |C |
|2 |E |
+----------+---------+
And my problem is that I wanted to fetch s_names from my 3rd table into 2nd block.
tbl3
+----------+---------+
|s_gr |s_name |
+----------+---------+
|80 |F |
|85 |G |
|84 |H |
|84 |I |
|80 |J |
+----------+---------+
Like this:
then after leaving S_GR field, it will fetch S_NAME from tbl3 that S_GR = 80 into the 2nd block
You can create two blocks :
for the 1st one, to have a block with no base table, create manually just by touching Data Blocks node
with mouse's cursor and then toggling the create icon (a green plus
sign ) and type a name blk_no. And add a field s_no on the canvas.
for the 2nd one use Data Block Wizard and choose Table or View type
for the type of the block. There select the table(tbl1)'s both columns
(s_no and name) as Database Items.
And then, the forms must invoke
Layout Wizard automatically as default, where choose only name column
as displayed and leave s_no hidden as to be . Name the block as blk_names. This is a base-table block, and Data Source Name of the block blk_names is the table tbl1.
By the way, set Number of Records Displayed property to 10 as an example, and convert the name of the field name to snames as in your question.
Set block's WHERE Clause (in Database node) as s_no = :blk_no.s_no at the Property Palette. After
all, create a KEY-NEXT-ITEM trigger on s_no field with the inline
code :
go_block('blk_names');
execute_query;
At the runtime you can enter an integer value( let's give 1 as an example ) for s_no and populate the names field by pressing enter key ( the records with A and D will appear )
A button might be added with WHEN-BUTTON-PRESSED trigger having the code :
go_block('blk_names');
delete tbl2;
first_record;
while :blk_names.s_no is not null
loop
insert into tbl2 values(:snames);
next_record;
end loop;
commit;
to populate and re-populate the table tbl2( in this case tbl2 is populated with the records A and D ).
P.S. To suppress the message
FRM-40352: Last Record of Query retrieved
add an ON-MESSAGE trigger at the forms level wtih the code :
if message_code = 40352 then
null;
end if;

Google Sheet Custom Formula for Duplicates in two columns

I've a working custom formula put in the data validation box in column A in a Google spreadsheet to disallow entering duplicates in the same column A.
=countif($A$3:$A$1677,A3)<=1
Now i have another column, column B, and i want the above formula to be moved in column B from column A editing it in such a way that it offers the following :
+---+------------+-------------+
| | A | B | <-- the custom formula to be kept in column B only (in the data validation box).
+---+------------+-------------+
| 1 | John | MySQL | <-- if this row/data is already existing, then
| 2 | John | Oracle | <-- this entry is allowed (bcoz the data in this row do not match with data in the above row (considering both columns), and
| 3 | Viv | MySQL | <-- this entry is also allowed (bcoz the data in this row also do not match with data in the above two rows (considering both columns), and
| 4 | Al | SQL | <-- this entry is also allowed (bcoz the data in this row also do not match with data in the above three rows (considering both columns), but,
| 5 | Viv | MySQL | <-- this entry is NOT allowed (bcoz the data in this row entirely match with data in one of the above rows - row no. 3 (considering both columns).
+---+------------+-------------+
I have modified the aforementioned formula a little as below :
=countif($A$3:$B$1677,B3)<=1
But it does not fulfill the 2nd condition (Viv, MySQL) stated above.
Try this:
=COUNTIF(ARRAYFORMULA($A$3:$A$1677&$B$3:$B$1677),A3&B3)<=1
Instead of checking each column separately, you just join the values together and check to see if more that one of joined string exists!
Hope that helps!

SSRS Group By Data in Row but Vertically

I have a problem to produce a SSRS report that is like this:
This is how my output from stored procedure looks like:
Company Code | Company Name | Product Code | Product Name
ICE001 | Nestle | ICE001a | Drumstick Chocolate
ICE001 | Nestle | ICE001b | Drumstick KitKat
ICE001 | Nestle | ICE001c | Drumstick Chocolate
ICE002 | Walls | ICE002a | Cornetto Chocolate
ICE002 | Walls | ICE002b | Cornetto Latte
ICE002 | Walls | ICE002c | Cornetto La Liga
So how can I achieve this report structure in SSRS with the current stored procedure? Is it achievable?
Actually, yes you can. These are the steps:
Drag a table into the SSRS.
Make it 2 columns and 1 row.
On the first column, select the field you want as the sub data which in this case, Product Code.
In 2nd column, put in Product Name.
Now for the main data. Right click on the first column, select:
Insert Row > Outside Group - Above
Put the main data field which is Company Code at the first row, first column.
Put the Company Name expression at the second column, first row of the table.
Design as your preferred and generate your report :)
Doubt it. But if you adjust your dataset as below and use a table report it is.
select distinct code,company from icecream
union
select productcode,productname from icecream

Hive: SemanticException [Error 10002]: Line 3:21 Invalid column reference 'name'

I am using the following hive query script for the version 0.13.0
DROP TABLE IF EXISTS movies.movierating;
DROP TABLE IF EXISTS movies.list;
DROP TABLE IF EXISTS movies.rating;
DROP DATABASE IF EXISTS movies;
ADD JAR /usr/local/hadoop/hive/hive/lib/RegexLoader.jar;
CREATE DATABASE IF NOT EXISTS movies;
CREATE EXTERNAL TABLE IF NOT EXISTS movies.list (id STRING, name STRING, genre STRING)
ROW FORMAT SERDE 'com.cisco.hadoop.loaders.RegexSerDe'with SERDEPROPERTIES(
"input.regex"="^(.*)\\:\\:(.*)\\:\\:(.*)$",
"output.format.string"="%1$s %2$s %3$s");
CREATE EXTERNAL TABLE IF NOT EXISTS movies.rating (id STRING, userid STRING, rating STRING, timestamp STRING)
ROW FORMAT SERDE 'com.cisco.hadoop.loaders.RegexSerDe'
with SERDEPROPERTIES(
"input.regex"="^(.*)\\:\\:(.*)\\:\\:(.*)\\:\\:(.*)$",
"output.format.string"="%1$s %2$s %3$s %4$s");
LOAD DATA LOCAL INPATH 'ml-10M100K/movies.dat' into TABLE movies.list;
LOAD DATA LOCAL INPATH 'ml-10M100K/ratings.dat' into TABLE movies.rating;
CREATE TABLE movies.movierating(id STRING, name STRING, genre STRING, rating STRING);
INSERT OVERWRITE TABLE movies.movierating
SELECT list.id, list.name, list.genre, rating.rating from movies.list list LEFT JOIN movies.rating rating ON (list.id=rating.id) GROUP BY list.id;
The issue is when I execute the script without the "GROUP BY" clause it works fine.
But when I execute it with the "GROUP BY" clause, I get the following error
FAILED: SemanticException [Error 10002]: Line 4:21 Invalid column reference 'name'
Any ideas what is happening here?
Appreciate your help
Thanks!
If you group by a column, your select statement can only select a) that column, b) columns derived only from that column, or c) a UDAF applied to other columns.
In this case, you're only grouping by list.id, so when you try to select list.name, that's invalid. Think about it this way: what if your list table contained the following two entries:
id|name |genre
--+-----+------
01|name1|comedy
01|name2|horror
What would you expect this query to return:
select list.id, list.name, list.genre from list group by list.id;
In this case it's nonsensical. I'm guessing that id in reality is a primary key, but note that hive does not know this, so the above data set is perfectly valid.
With all that in mind, it's not clear to me how to fix it because I don't know the desired output. For example, let's say without the group by (just the join), you have as output:
id|name |genre |rating
--+-----+------+-------
01|name1|comedy|'pretty good'
01|name1|comedy|'bad'
02|name2|horror|'9/10'
03|name3|action|NULL
What would you want the output to be with the group by? What are you trying to accomplish by doing the group by?
OK let me see if I can ask this in a better way.
Here are my two tables
Movies list table - Consists of movies information
ID | Movie Name | Genre
1 | Movie 1 | comedy
2 | movie 2 | action
3 | movie 3 | thriller
And I have ratings table
MOVIE_ID | USER ID | RATING on 5 | TIMESTAMP
1 | xyz | 5 | 12345612
1 | abc | 4 | 23232312
2 | zvc | 1 | 12321123
2 | zyx | 2 | 12312312
What I would like to do is get the output in the following way:
Movie ID | Movie Name | Genre | Rating Average
1 | Movie 1 | comedy | 4.5
2 | Movie 2 | action | 1.5
I am not a db expert but I understand this, when you group the data together you need to convert the multiple values to the scalar values or all the values, if string should be same right?
For example in my previous case, I was grouping them together as a string. So which is okay for list.id, list.name and list.genre, but the list.rating, well that is always going to give some problem here (I just learnt PIG along with hive, so grouping works differently there)
So to tackle the problem, I casted the rating and averaged it out and stored it in the float table. Have a look at my code below:
CREATE TABLE movies.movierating(id STRING, name STRING, genre STRING, rating FLOAT);
INSERT OVERWRITE TABLE movies.movierating
SELECT list.id, list.name, list.genre, AVG(cast(rating.rating as FLOAT)) from movies.list list LEFT JOIN movies.rating rating ON (list.id=rating.id) GROUP BY list.id, list.name,list.genre order by list.id DESC;
Thank you for your explanation. I might save the following question for the next thread but here is my observation:
The performance of the Overall job is reduced when performing Grouping and Joining together than to do it in two separate queries. For the same job, I had changed the code a bit to perform the grouping first and then joining the data and the over all time was reduced by 40 seconds. Earlier it was taking 140 seconds and now it is taking 100 seconds. Any reasons to that?
Once again thank you for your explanation.
I came across same issue:
org.apache.hadoop.hive.ql.parse.SemanticException: Invalid column reference "charge_province"
After I put the "charge_province" in the group by, the issue is gone. I don't know why.

Resources