What happened

Shares of infrastructure construction company MasTec (MTZ 0.62%) got a 22.5% boost in August, according to data provided by S&P Global Market Intelligence. The rise marks yet another strong month for the stock -- a move seemingly at odds with the rest of the industrial sector, with the catalyst being an excellent set of second-quarter earnings

In a nutshell, MasTec's main end markets -- oil and gas pipelines and communications wireless network construction (AT&T is its single biggest customer, generating 23% of total revenue in 2018) -- are in good shape in 2019. Moreover, MasTec's other two smaller segments, namely power generation and industrial and electrical transmission, "performed above expectations," according to CEO Jose Mas on the earnings call.

Wireless towers against a city skyline.

Image source: Getty Images.

Oil and gas segment revenue rose a whopping 22% to $937 million in the second quarter, driven by the need to increase takeaway capacity in the U.S. and particularly in the Permian Basin -- MasTec is a key player in the region. CFO George Pita said the segment's performance was better than expected in the quarter "due to project productivity on numerous small pipeline projects." 

Turning to the communications segment, revenue growth was only 5.5%, to $653 million, but it's important to note that management expects 5G to spur a pickup in growth going forward. Pita anticipates the segment's second-half revenue to grow by low double digits compared to the first half of 2019, as well as strong results and margin expansion in 2020.

Electrical transmission revenue went up 19% to $100 million, and power generation and industrial revenue vaulted 71% to $250 million, but to put the two segments' importance in context, their combined contribution to adjusted earnings before interest, tax, depreciation, and amortization (EBITDA) was just 7.3% in the second quarter.

So what

It was an excellent quarter for the company and MasTec took full advantage of pipeline spending in the Permian Basin, but the question is what will happen next year. Once the takeaway capacity has been increased, MasTec's prospects will appear to be challenged if oil prices weaken and take the U.S. rig count down with it. Investing in the energy sector usually involves taking a view on energy prices. 

US Oil Rig Count Chart

US oil rig count. Data by YCharts.

That said, communications looks set for strong growth, with 5G spending kicking in and the power generation and industrial and transmission segments have growth prospects from the expansion of renewable energy.

Now what

This year will be a strong one for MasTec but analysts have earnings per share rising just 5.3% in 2020 and companies like process automation company Emerson Electric have made ominous comments about delays in oil and gas infrastructure spending. Investors will be hoping for oil prices to climb and create a second wind for pipeline spending. Meanwhile, the growth baton will pass on to the communications segment in 2020. Hopefully, it will be enough to keep the company's earnings growing.