Really? Which ones?
Any daytime train won't be a problem - you will have (maybe not required, but bring one regardless) to have the dog muzzled and you will require extra tickets for the dog, but it's nothing extraordinary. If you want to do it, the best option is as follows -
Depart Budapest-Keleti 05:28, arrive Breclav 08:59
Depart Breclav 09:08, arrive Warszawa Centralna 15:32
Depart Warszawa Centralna 16:57, arrive Gdansk Glowny 22:12
rozklad-pkp.pl for timetable details.
The best bet would be to buy a ticket in Budapest direct to Gdansk - it's perfectly possible, and while you won't get the best possible fare, it will mean that you have everything sorted.
The Polish rules are here - intercity.pl/?page=przewoz_psa.