edoar94
Erlang QLC Joins - trying merge two tables but result data is duplicated
Hi, someone have some Erlang qlc join examples? i’m trying merge two tables but result data is duplicated. i write this qlc:
disk_partitions() ->
mnesia:transaction(
fun() ->
qlc:eval(
qlc:q([
{D0, D1, D2, D3, P, D5, D6} ||
{D0, D1, D2, D3, _D4, D5, D6} <- mnesia:table(disk),
P = {_P0, P1, _P2, _P3, _P4, _P5, _P6, _P7} <- mnesia:table(partition),
D1 =:= re:replace(P1, "[0-9]+", "", [{return, binary}])
])
)
end
).
and returned this:
iex(43)> :join_queries.disk_partitions
{:atomic,
[
{:disk, "/dev/sdb", "101 GT", "dos",
{:partition, "/dev/sdb1", [], "Test", true, "/some/fake/path", "fat32",
"UU82-3O93"}, "AB87-3S21", "TOSHIBA"},
{:disk, "/dev/sdb", "101 GT", "dos",
{:partition, "/dev/sdb2", [], "2Record", false, "fake_point", "exfat",
"som2_3de2"}, "AB87-3S21", "TOSHIBA"}
]}
i want some like this
{:atomic,
[
{:disk, "/dev/sdb", "101 GT", "dos",
[{:partition, "/dev/sdb1", [], "Test", true, "/some/fake/path", "fat32",
"UU82-3O93"}, {:partition, "/dev/sdb2", [], "2Record", false, "fake_point", "exfat", "som2_3de2"}] "AB87-3S21", "TOSHIBA"}
]}
when i tried adding {join, merge} i got the error:
iex(9)> :join_queries.disk_partitions
{:aborted,
{:no_join_to_carry_out,
[
{:qlc, :check_join_option, [join: :merge], [file: 'qlc.erl', line: 2202]},
{:qlc, :prep_join, 3, [file: 'qlc.erl', line: 2062]},
{:qlc, :prepare_qlc, 7, [file: 'qlc.erl', line: 1672]},
{:qlc, :eval, 2, [file: 'qlc.erl', line: 293]},
{:mnesia_tm, :apply_fun, 3, [file: 'mnesia_tm.erl', line: 842]},
{:mnesia_tm, :execute_transaction, 5, [file: 'mnesia_tm.erl', line: 818]},
{:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 685]},
{:elixir, :recur_eval, 3, [file: 'src/elixir.erl', line: 280]},
{:elixir, :eval_forms, 3, [file: 'src/elixir.erl', line: 265]},
{IEx.Evaluator, :handle_eval, 3, [file: 'lib/iex/evaluator.ex', line: 298]},
{IEx.Evaluator, :do_eval, 3, [file: 'lib/iex/evaluator.ex', line: 274]},
{IEx.Evaluator, :eval, 3, [file: 'lib/iex/evaluator.ex', line: 263]},
{IEx.Evaluator, :loop, 1, [file: 'lib/iex/evaluator.ex', line: 157]},
{IEx.Evaluator, :init, 4, [file: 'lib/iex/evaluator.ex', line: 32]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}
]}}
i readed erlang docs but idk how can i make to work the qlc joins.
Thanks.
First Post!
Kozaky
Hi,
I am currently facing the same issue, looking to make a join with a second table using a list of ids stored in the first table. Were you finally able to find a solution for the merge error?
Thank you in advance
Popular in Questions
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it.
I’m very interested in Elixir,...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Other popular topics
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New







